Esempio n. 1
0
void FormatterSettings::ApplyTo(astyle::ASFormatter& formatter)
{
  // NOTE: Keep this in sync with DlgFormatterSettings::ApplyTo
  ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("astyle"));

  int style = cfg->ReadInt(_T("/style"), 0);

  switch (style)
  {
    case aspsAllman: // Allman (ANSI)
      formatter.setFormattingStyle(astyle::STYLE_ALLMAN);
      break;

    case aspsJava: // Java
      formatter.setFormattingStyle(astyle::STYLE_JAVA);
      break;

    case aspsKr: // K&R
      formatter.setFormattingStyle(astyle::STYLE_KR);
      break;

    case aspsStroustrup: // Stroustrup
      formatter.setFormattingStyle(astyle::STYLE_STROUSTRUP);
      break;

    case aspsWhitesmith: // Whitesmith
      formatter.setFormattingStyle(astyle::STYLE_WHITESMITH);
      break;

    case aspsBanner: // Banner
      formatter.setFormattingStyle(astyle::STYLE_BANNER);
      break;

    case aspsGnu: // GNU
      formatter.setFormattingStyle(astyle::STYLE_GNU);
      break;

    case aspsLinux: // Linux
      formatter.setFormattingStyle(astyle::STYLE_LINUX);
      break;

    case aspsHorstmann: // Horstmann
      formatter.setFormattingStyle(astyle::STYLE_HORSTMANN);
      break;

    case asps1TBS: // 1TBS
      formatter.setFormattingStyle(astyle::STYLE_1TBS);
      break;

    case aspsPico: // Pico
      formatter.setFormattingStyle(astyle::STYLE_PICO);
      break;

    case aspsLisp: // Lisp
      formatter.setFormattingStyle(astyle::STYLE_LISP);
      break;

    default: // Custom
      break;
  }

  bool value = cfg->ReadBool(_T("/force_tabs"));
  int spaceNum = cfg->ReadInt(_T("/indentation"), 4);

  if (cfg->ReadBool(_T("/use_tabs")))
    formatter.setTabIndentation(spaceNum, value);
  else
    formatter.setSpaceIndentation(spaceNum);

  formatter.setClassIndent(cfg->ReadBool(_T("/indent_classes")));
  formatter.setSwitchIndent(cfg->ReadBool(_T("/indent_switches")));
  formatter.setCaseIndent(cfg->ReadBool(_T("/indent_case")));
  formatter.setBracketIndent(cfg->ReadBool(_T("/indent_brackets")));
  formatter.setBlockIndent(cfg->ReadBool(_T("/indent_blocks")));
  formatter.setNamespaceIndent(cfg->ReadBool(_T("/indent_namespaces")));
  formatter.setLabelIndent(cfg->ReadBool(_T("/indent_labels")));
  formatter.setPreprocessorIndent(cfg->ReadBool(_T("/indent_preprocessor")));
  formatter.setIndentCol1CommentsMode(cfg->ReadBool(_T("/indent_col1_comments")));

  wxString pointerAlign = cfg->Read(_T("/pointer_align"));

  if      (pointerAlign == _T("Type"))
    formatter.setPointerAlignment(astyle::PTR_ALIGN_TYPE);
  else if (pointerAlign == _T("Middle"))
    formatter.setPointerAlignment(astyle::PTR_ALIGN_MIDDLE);
  else if (pointerAlign == _T("Name"))
    formatter.setPointerAlignment(astyle::PTR_ALIGN_NAME);
  else
    formatter.setPointerAlignment(astyle::PTR_ALIGN_NONE);

  formatter.setBreakClosingHeaderBracketsMode(cfg->ReadBool(_T("/break_closing")));
  formatter.setBreakBlocksMode(cfg->ReadBool(_T("/break_blocks")));
  formatter.setBreakElseIfsMode(cfg->ReadBool(_T("/break_elseifs")));
  formatter.setOperatorPaddingMode(cfg->ReadBool(_T("/pad_operators")));
  formatter.setParensOutsidePaddingMode(cfg->ReadBool(_T("/pad_parentheses_out")));
  formatter.setParensInsidePaddingMode(cfg->ReadBool(_T("/pad_parentheses_in")));
  formatter.setParensHeaderPaddingMode(cfg->ReadBool(_T("/pad_header")));
  formatter.setParensUnPaddingMode(cfg->ReadBool(_T("/unpad_parentheses")));
  formatter.setDeleteEmptyLinesMode(cfg->ReadBool(_T("/delete_empty_lines")));
  formatter.setSingleStatementsMode(!cfg->ReadBool(_T("/keep_complex")));
  formatter.setBreakOneLineBlocksMode(!cfg->ReadBool(_T("/keep_blocks")));
  formatter.setTabSpaceConversionMode(cfg->ReadBool(_T("/convert_tabs")));
  formatter.setEmptyLineFill(cfg->ReadBool(_T("/fill_empty_lines")));
  formatter.setAddBracketsMode(cfg->ReadBool(_T("/add_brackets")));
}
void dlgFormatterSettings::ApplyTo(astyle::ASFormatter& formatter)
{
    if (XRCCTRL(*m_dlg, "rbAllman", wxRadioButton)->GetValue())
        formatter.setFormattingStyle(astyle::STYLE_ALLMAN);
    else if (XRCCTRL(*m_dlg, "rbJava", wxRadioButton)->GetValue())
        formatter.setFormattingStyle(astyle::STYLE_JAVA);
    else if (XRCCTRL(*m_dlg, "rbKr", wxRadioButton)->GetValue())
        formatter.setFormattingStyle(astyle::STYLE_KandR);
    else if (XRCCTRL(*m_dlg, "rbStroustrup", wxRadioButton)->GetValue())
        formatter.setFormattingStyle(astyle::STYLE_STROUSTRUP);
    else if (XRCCTRL(*m_dlg, "rbWhitesmith", wxRadioButton)->GetValue())
        formatter.setFormattingStyle(astyle::STYLE_WHITESMITH);
    else if (XRCCTRL(*m_dlg, "rbBanner", wxRadioButton)->GetValue())
        formatter.setFormattingStyle(astyle::STYLE_BANNER);
    else if (XRCCTRL(*m_dlg, "rbGNU", wxRadioButton)->GetValue())
        formatter.setFormattingStyle(astyle::STYLE_GNU);
    else if (XRCCTRL(*m_dlg, "rbLinux", wxRadioButton)->GetValue())
        formatter.setFormattingStyle(astyle::STYLE_LINUX);
    else if (XRCCTRL(*m_dlg, "rbHorstmann", wxRadioButton)->GetValue())
        formatter.setFormattingStyle(astyle::STYLE_HORSTMANN);
    else if (XRCCTRL(*m_dlg, "rbCustom", wxRadioButton)->GetValue())
    {
        bool value = XRCCTRL(*m_dlg, "chkForceUseTabs", wxCheckBox)->GetValue();
        int spaceNum = XRCCTRL(*m_dlg, "spnIndentation", wxSpinCtrl)->GetValue();

        if (XRCCTRL(*m_dlg, "chkUseTab", wxCheckBox)->GetValue())
        {
            formatter.setTabIndentation(spaceNum, value);
        }
        else
        {
            formatter.setSpaceIndentation(spaceNum);
        }

        formatter.setClassIndent(XRCCTRL(*m_dlg, "chkIndentClasses", wxCheckBox)->GetValue());
        formatter.setSwitchIndent(XRCCTRL(*m_dlg, "chkIndentSwitches", wxCheckBox)->GetValue());
        formatter.setCaseIndent(XRCCTRL(*m_dlg, "chkIndentCase", wxCheckBox)->GetValue());
        formatter.setBracketIndent(XRCCTRL(*m_dlg, "chkIndentBrackets", wxCheckBox)->GetValue());
        formatter.setBlockIndent(XRCCTRL(*m_dlg, "chkIndentBlocks", wxCheckBox)->GetValue());
        formatter.setNamespaceIndent(XRCCTRL(*m_dlg, "chkIndentNamespaces", wxCheckBox)->GetValue());
        formatter.setLabelIndent(XRCCTRL(*m_dlg, "chkIndentLabels", wxCheckBox)->GetValue());
        formatter.setPreprocessorIndent(XRCCTRL(*m_dlg, "chkIndentPreprocessor", wxCheckBox)->GetValue());

        wxString brackedFormatMode = XRCCTRL(*m_dlg, "cmbBracketFormatMode", wxComboBox)->GetValue();

        if (brackedFormatMode == _T("Attach"))
        {
            formatter.setBracketFormatMode(astyle::ATTACH_MODE);
        }
        else if (brackedFormatMode == _T("Break"))
        {
            formatter.setBracketFormatMode(astyle::BREAK_MODE);
        }
        else if (brackedFormatMode == _T("Linux"))
        {
            formatter.setBracketFormatMode(astyle::LINUX_MODE);
        }
        else if (brackedFormatMode == _T("Stroustrup"))
        {
            formatter.setBracketFormatMode(astyle::STROUSTRUP_MODE);
        }
        else
        {
            formatter.setBracketFormatMode(astyle::NONE_MODE);
        }

        wxString pointerAlign = XRCCTRL(*m_dlg, "cmbPointerAlign", wxComboBox)->GetValue();

        if (pointerAlign == _T("Type"))
        {
            formatter.setPointerAlignment(astyle::ALIGN_TYPE);
        }
        else if (pointerAlign == _T("Middle"))
        {
            formatter.setPointerAlignment(astyle::ALIGN_MIDDLE);
        }
        else if (pointerAlign == _T("Name"))
        {
            formatter.setPointerAlignment(astyle::ALIGN_NAME);
        }
        else
        {
            formatter.setPointerAlignment(astyle::ALIGN_NONE);
        }

        formatter.setBreakClosingHeaderBracketsMode(XRCCTRL(*m_dlg, "chkBreakClosing", wxCheckBox)->GetValue());
        formatter.setBreakBlocksMode(XRCCTRL(*m_dlg, "chkBreakBlocks", wxCheckBox)->GetValue());
        formatter.setBreakElseIfsMode(XRCCTRL(*m_dlg, "chkBreakElseIfs", wxCheckBox)->GetValue());
        formatter.setOperatorPaddingMode(XRCCTRL(*m_dlg, "chkPadOperators", wxCheckBox)->GetValue());
        formatter.setParensOutsidePaddingMode(XRCCTRL(*m_dlg, "chkPadParensOut", wxCheckBox)->GetValue());
        formatter.setParensInsidePaddingMode(XRCCTRL(*m_dlg, "chkPadParensIn", wxCheckBox)->GetValue());
        formatter.setParensUnPaddingMode(XRCCTRL(*m_dlg, "chkUnpadParens", wxCheckBox)->GetValue());
        formatter.setSingleStatementsMode(!XRCCTRL(*m_dlg, "chkKeepComplex", wxCheckBox)->GetValue());
        formatter.setBreakOneLineBlocksMode(!XRCCTRL(*m_dlg, "chkKeepBlocks", wxCheckBox)->GetValue());
        formatter.setTabSpaceConversionMode(XRCCTRL(*m_dlg, "chkConvertTabs", wxCheckBox)->GetValue());
        formatter.setEmptyLineFill(XRCCTRL(*m_dlg, "chkFillEmptyLines", wxCheckBox)->GetValue());
    }
}
void FormatterSettings::ApplyTo(astyle::ASFormatter& formatter)
{
  // NOTE: Keep this in sync with DlgFormatterSettings::ApplyTo
  wxConfigBase	  *cfg=wxConfigBase::Get(false);
  wxString oldpath=cfg->GetPath();
  cfg->SetPath(wxT("/astyle"));
  //ConfigManager* cfg = Manager::Get()->GetConfigManager(wxT("astyle"));

  long style = cfg->ReadLong(wxT("style"), aspsAllman);
  switch (style)
  {
    case aspsAllman: // Allman (ANSI)
      formatter.setFormattingStyle(astyle::STYLE_ALLMAN);
      break;

    case aspsJava: // Java
      formatter.setFormattingStyle(astyle::STYLE_JAVA);
      break;

    case aspsKr: // K&R
      formatter.setFormattingStyle(astyle::STYLE_KR);
      break;

    case aspsStroustrup: // Stroustrup
      formatter.setFormattingStyle(astyle::STYLE_STROUSTRUP);
      break;

    case aspsWhitesmith: // Whitesmith
      formatter.setFormattingStyle(astyle::STYLE_WHITESMITH);
      break;

    case aspsVTK: // VTK
      formatter.setFormattingStyle(astyle::STYLE_VTK);
      break;

    case aspsBanner: // Banner
      formatter.setFormattingStyle(astyle::STYLE_BANNER);
      break;

    case aspsGnu: // GNU
      formatter.setFormattingStyle(astyle::STYLE_GNU);
      break;

    case aspsLinux: // Linux
      formatter.setFormattingStyle(astyle::STYLE_LINUX);
      break;

    case aspsHorstmann: // Horstmann
      formatter.setFormattingStyle(astyle::STYLE_HORSTMANN);
      break;

    case asps1TBS: // 1TBS
      formatter.setFormattingStyle(astyle::STYLE_1TBS);
      break;

    case aspsGoogle: // Google
      formatter.setFormattingStyle(astyle::STYLE_GOOGLE);
      break;

    case aspsPico: // Pico
      formatter.setFormattingStyle(astyle::STYLE_PICO);
      break;

    case aspsLisp: // Lisp
      formatter.setFormattingStyle(astyle::STYLE_LISP);
      break;

    default: // Custom
      break;
  }

  formatter.setAttachClass(cfg->ReadBool(wxT("attach_classes"), false));
  formatter.setAttachExternC(cfg->ReadBool(wxT("attach_extern_c"), true));
  formatter.setAttachNamespace(cfg->ReadBool(wxT("attach_namespaces"), true));
  formatter.setAttachInline(cfg->ReadBool(wxT("attach_inlines"), true));

  bool value = cfg->ReadBool(wxT("force_tabs"), false);
  long spaceNum = cfg->ReadLong(wxT("indentation"), 4);
  if (cfg->ReadBool(wxT("use_tabs"), false))
    formatter.setTabIndentation(spaceNum, value);
  else
    formatter.setSpaceIndentation(spaceNum);

  formatter.setCaseIndent(cfg->ReadBool(wxT("indent_case"), true));
  formatter.setClassIndent(cfg->ReadBool(wxT("indent_classes"), false));
  formatter.setLabelIndent(cfg->ReadBool(wxT("indent_labels"), false));
  formatter.setModifierIndent(cfg->ReadBool(wxT("indent_modifiers"), false));
  formatter.setNamespaceIndent(cfg->ReadBool(wxT("indent_namespaces"), true));
  formatter.setSwitchIndent(cfg->ReadBool(wxT("indent_switches"), false));
  formatter.setPreprocBlockIndent(cfg->ReadBool(wxT("indent_preproc_block"), true));
  formatter.setPreprocDefineIndent(cfg->ReadBool(wxT("indent_preproc_define"), false));
  formatter.setPreprocConditionalIndent(cfg->ReadBool(wxT("indent_preproc_cond"), false));
  formatter.setIndentCol1CommentsMode(cfg->ReadBool(wxT("indent_col1_comments"), true));
  formatter.setMinConditionalIndentOption(cfg->ReadLong(wxT("min_conditional_indent"), 2));
  formatter.setMaxInStatementIndentLength(cfg->ReadLong(wxT("max_instatement_indent"), 40));

  formatter.setBreakClosingHeaderBracketsMode(cfg->ReadBool(wxT("break_closing"), true));
  formatter.setBreakElseIfsMode(cfg->ReadBool(wxT("break_elseifs"), true));
  formatter.setAddBracketsMode(cfg->ReadBool(wxT("add_brackets"), false));
  formatter.setAddOneLineBracketsMode(cfg->ReadBool(wxT("add_one_line_brackets"), true));
  formatter.setSingleStatementsMode(!cfg->ReadBool(wxT("keep_complex"), true));
  formatter.setRemoveBracketsMode(cfg->ReadBool(wxT("remove_brackets"), false));
  formatter.setBreakOneLineBlocksMode(!cfg->ReadBool(wxT("keep_blocks"), true));
  formatter.setTabSpaceConversionMode(cfg->ReadBool(wxT("convert_tabs"), true));
  formatter.setCloseTemplatesMode(cfg->ReadBool(wxT("close_templates"), false));
  formatter.setStripCommentPrefix(cfg->ReadBool(wxT("remove_comment_prefix"), false));

  if (cfg->ReadBool(wxT("break_lines"), false))
  {
    formatter.setMaxCodeLength(wxAtoi(cfg->Read(wxT("max_line_length"), wxString(wxT("256")))));
    formatter.setBreakAfterMode(cfg->ReadBool(wxT("break_after_mode"), false));
  }
  else
    //formatter.setMaxCodeLength(INT_MAX);
    formatter.setMaxCodeLength(4096); //DEFAULT_MAX_LINELEN

  formatter.setBreakBlocksMode(cfg->ReadBool(wxT("break_blocks"), true));
  formatter.setBreakClosingHeaderBlocksMode(cfg->ReadBool(wxT("break_blocks_all"), false));
  formatter.setOperatorPaddingMode(cfg->ReadBool(wxT("pad_operators"), true));
  formatter.setParensOutsidePaddingMode(cfg->ReadBool(wxT("pad_parentheses_out"), false));
  formatter.setParensInsidePaddingMode(cfg->ReadBool(wxT("pad_parentheses_in"), true));
  formatter.setParensHeaderPaddingMode(cfg->ReadBool(wxT("pad_header"), false));
  formatter.setParensUnPaddingMode(cfg->ReadBool(wxT("unpad_parentheses"), true));
  formatter.setDeleteEmptyLinesMode(cfg->ReadBool(wxT("delete_empty_lines"), true));
  formatter.setEmptyLineFill(cfg->ReadBool(wxT("fill_empty_lines"), false));

  wxString pointerAlign = cfg->Read(wxT("pointer_align"), wxEmptyString);
  if      (pointerAlign == wxT("Type"))
    formatter.setPointerAlignment(astyle::PTR_ALIGN_TYPE);
  else if (pointerAlign == wxT("Middle"))
    formatter.setPointerAlignment(astyle::PTR_ALIGN_MIDDLE);
  else if (pointerAlign == wxT("Name"))
    formatter.setPointerAlignment(astyle::PTR_ALIGN_NAME);
  else
    formatter.setPointerAlignment(astyle::PTR_ALIGN_NONE);

  wxString referenceAlign = cfg->Read(wxT("reference_align"), wxEmptyString);
  if      (referenceAlign == wxT("Type"))
    formatter.setReferenceAlignment(astyle::REF_ALIGN_TYPE);
  else if (referenceAlign == wxT("Middle"))
    formatter.setReferenceAlignment(astyle::REF_ALIGN_MIDDLE);
  else if (referenceAlign == wxT("Name"))
    formatter.setReferenceAlignment(astyle::REF_ALIGN_NAME);
  else
    formatter.setReferenceAlignment(astyle::REF_ALIGN_NONE);
  
  cfg->SetPath(oldpath);
}
Esempio n. 4
0
void FormatterSettings::ApplyTo(astyle::ASFormatter& formatter)
{
  ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("astyle"));

  int style = cfg->ReadInt(_T("/style"), 0);

  switch (style)
  {
    case aspsAllman: // Allman (ANSI)
      formatter.setFormattingStyle(astyle::STYLE_ALLMAN);
      break;

    case aspsJava: // Java
      formatter.setFormattingStyle(astyle::STYLE_JAVA);
      break;

    case aspsKr: // K&R
      formatter.setFormattingStyle(astyle::STYLE_KandR);
      break;

    case aspsStroustrup: // Stroustrup
      formatter.setFormattingStyle(astyle::STYLE_STROUSTRUP);
      break;

    case aspsWhitesmith: // Whitesmith
      formatter.setFormattingStyle(astyle::STYLE_WHITESMITH);
      break;

    case aspsBanner: // Banner
      formatter.setFormattingStyle(astyle::STYLE_BANNER);
      break;

    case aspsGnu: // GNU
      formatter.setFormattingStyle(astyle::STYLE_GNU);
      break;

    case aspsLinux: // Linux
      formatter.setFormattingStyle(astyle::STYLE_LINUX);
      break;

    case aspsHorstmann: // Horstmann
      formatter.setFormattingStyle(astyle::STYLE_HORSTMANN);
      break;

    default: // Custom
    {
      bool value = cfg->ReadBool(_T("/force_tabs"));
      int spaceNum = cfg->ReadInt(_T("/indentation"), 4);

      if (cfg->ReadBool(_T("/use_tabs")))
      {
        formatter.setTabIndentation(spaceNum, value);
      }
      else
      {
        formatter.setSpaceIndentation(spaceNum);
      }

      formatter.setClassIndent(cfg->ReadBool(_T("/indent_classes")));
      formatter.setSwitchIndent(cfg->ReadBool(_T("/indent_switches")));
      formatter.setCaseIndent(cfg->ReadBool(_T("/indent_case")));
      formatter.setBracketIndent(cfg->ReadBool(_T("/indent_brackets")));
      formatter.setBlockIndent(cfg->ReadBool(_T("/indent_blocks")));
      formatter.setNamespaceIndent(cfg->ReadBool(_T("/indent_namespaces")));
      formatter.setLabelIndent(cfg->ReadBool(_T("/indent_labels")));
      formatter.setPreprocessorIndent(cfg->ReadBool(_T("/indent_preprocessor")));

      wxString brackedFormatMode = cfg->Read(_T("/bracket_format_mode"));

      if (brackedFormatMode == _T("Attach"))
      {
        formatter.setBracketFormatMode(astyle::ATTACH_MODE);
      }
      else if (brackedFormatMode == _T("Break"))
      {
        formatter.setBracketFormatMode(astyle::BREAK_MODE);
      }
      else if (brackedFormatMode == _T("Linux"))
      {
        formatter.setBracketFormatMode(astyle::LINUX_MODE);
      }
      else if (brackedFormatMode == _T("Stroustrup"))
      {
        formatter.setBracketFormatMode(astyle::STROUSTRUP_MODE);
      }
      else
      {
        formatter.setBracketFormatMode(astyle::NONE_MODE);
      }

      wxString pointerAlign = cfg->Read(_T("/pointer_align"));

      if (pointerAlign == _T("Type"))
      {
        formatter.setPointerAlignment(astyle::ALIGN_TYPE);
      }
      else if (pointerAlign == _T("Middle"))
      {
        formatter.setPointerAlignment(astyle::ALIGN_MIDDLE);
      }
      else if (pointerAlign == _T("Name"))
      {
        formatter.setPointerAlignment(astyle::ALIGN_NAME);
      }
      else
      {
        formatter.setPointerAlignment(astyle::ALIGN_NONE);
      }

      formatter.setBreakClosingHeaderBracketsMode(cfg->ReadBool(_T("/break_closing")));
      formatter.setBreakBlocksMode(cfg->ReadBool(_T("/break_blocks")));
      formatter.setBreakElseIfsMode(cfg->ReadBool(_T("/break_elseifs")));
      formatter.setOperatorPaddingMode(cfg->ReadBool(_T("/pad_operators")));
      formatter.setParensOutsidePaddingMode(cfg->ReadBool(_T("/pad_parentheses_out")));
      formatter.setParensInsidePaddingMode(cfg->ReadBool(_T("/pad_parentheses_in")));
      formatter.setParensUnPaddingMode(cfg->ReadBool(_T("/unpad_parentheses")));
      formatter.setSingleStatementsMode(!cfg->ReadBool(_T("/keep_complex")));
      formatter.setBreakOneLineBlocksMode(!cfg->ReadBool(_T("/keep_blocks")));
      formatter.setTabSpaceConversionMode(cfg->ReadBool(_T("/convert_tabs")));
      formatter.setEmptyLineFill(cfg->ReadBool(_T("/fill_empty_lines")));
      break;
    }
  }
}
void FormatterSettings::ApplyTo(astyle::ASFormatter& formatter)
{
  // NOTE: Keep this in sync with DlgFormatterSettings::ApplyTo
  ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("astyle"));

  int style = cfg->ReadInt(_T("/style"), 0);
  switch (style)
  {
    case aspsAllman: // Allman (ANSI)
      formatter.setFormattingStyle(astyle::STYLE_ALLMAN);
      break;

    case aspsJava: // Java
      formatter.setFormattingStyle(astyle::STYLE_JAVA);
      break;

    case aspsKr: // K&R
      formatter.setFormattingStyle(astyle::STYLE_KR);
      break;

    case aspsStroustrup: // Stroustrup
      formatter.setFormattingStyle(astyle::STYLE_STROUSTRUP);
      break;

    case aspsWhitesmith: // Whitesmith
      formatter.setFormattingStyle(astyle::STYLE_WHITESMITH);
      break;

    case aspsVTK: // VTK
      formatter.setFormattingStyle(astyle::STYLE_VTK);
      break;

    case aspsRatliff: // Ratliff
      formatter.setFormattingStyle(astyle::STYLE_RATLIFF);
      break;

    case aspsGnu: // GNU
      formatter.setFormattingStyle(astyle::STYLE_GNU);
      break;

    case aspsLinux: // Linux
      formatter.setFormattingStyle(astyle::STYLE_LINUX);
      break;

    case aspsHorstmann: // Horstmann
      formatter.setFormattingStyle(astyle::STYLE_HORSTMANN);
      break;

    case asps1TBS: // 1TBS
      formatter.setFormattingStyle(astyle::STYLE_1TBS);
      break;

    case aspsGoogle: // Google
      formatter.setFormattingStyle(astyle::STYLE_GOOGLE);
      break;

    case aspsMozilla: // Mozilla
      formatter.setFormattingStyle(astyle::STYLE_MOZILLA);
      break;

    case aspsPico: // Pico
      formatter.setFormattingStyle(astyle::STYLE_PICO);
      break;

    case aspsLisp: // Lisp
      formatter.setFormattingStyle(astyle::STYLE_LISP);
      break;

    default: // Custom
      break;
  }

  formatter.setAttachClass(cfg->ReadBool(_T("/attach_classes")));
  formatter.setAttachExternC(cfg->ReadBool(_T("/attach_extern_c")));
  formatter.setAttachNamespace(cfg->ReadBool(_T("/attach_namespaces")));
  formatter.setAttachInline(cfg->ReadBool(_T("/attach_inlines")));

  int spaceNum = cfg->ReadInt(_T("/indentation"), 4);
  bool value = cfg->ReadBool(_T("/force_tabs"));
  if (cfg->ReadBool(_T("/use_tabs")))
    formatter.setTabIndentation(spaceNum, value);
  else
    formatter.setSpaceIndentation(spaceNum);

  int contNum = cfg->ReadInt(_T("/continuation"), 0);
  if (contNum>0 && contNum<=4)
    formatter.setContinuationIndentation(contNum);

  formatter.setCaseIndent(cfg->ReadBool(_T("/indent_case")));
  formatter.setClassIndent(cfg->ReadBool(_T("/indent_classes")));
  formatter.setLabelIndent(cfg->ReadBool(_T("/indent_labels")));
  formatter.setModifierIndent(cfg->ReadBool(_T("/indent_modifiers")));
  formatter.setNamespaceIndent(cfg->ReadBool(_T("/indent_namespaces")));
  formatter.setSwitchIndent(cfg->ReadBool(_T("/indent_switches")));
  formatter.setPreprocBlockIndent(cfg->ReadBool(_T("/indent_preproc_block")));
  formatter.setPreprocDefineIndent(cfg->ReadBool(_T("/indent_preproc_define")));
  formatter.setPreprocConditionalIndent(cfg->ReadBool(_T("/indent_preproc_cond")));
  formatter.setIndentCol1CommentsMode(cfg->ReadBool(_T("/indent_col1_comments")));
  formatter.setMinConditionalIndentOption(cfg->ReadInt(_T("/min_conditional_indent"), 2));
  formatter.setMaxInStatementIndentLength(cfg->ReadInt(_T("/max_instatement_indent"), 40));

  formatter.setBreakClosingHeaderBracesMode(cfg->ReadBool(_T("/break_closing")));
  formatter.setBreakElseIfsMode(cfg->ReadBool(_T("/break_elseifs")));
  formatter.setAddBracketsMode(cfg->ReadBool(_T("/add_brackets")));
  formatter.setAddOneLineBracketsMode(cfg->ReadBool(_T("/add_one_line_brackets")));
  formatter.setRemoveBracketsMode(cfg->ReadBool(_T("/remove_brackets")));
  formatter.setBreakOneLineBlocksMode(!cfg->ReadBool(_T("/keep_blocks")));
  formatter.setBreakOneLineHeadersMode(cfg->ReadBool(_T("/keep_headers")));
  formatter.setBreakOneLineStatementsMode(!cfg->ReadBool(_T("/keep_statements")));
  formatter.setTabSpaceConversionMode(cfg->ReadBool(_T("/convert_tabs")));
  formatter.setCloseTemplatesMode(cfg->ReadBool(_T("/close_templates")));
  formatter.setStripCommentPrefix(cfg->ReadBool(_T("/remove_comment_prefix")));

  if (cfg->ReadBool(_T("/break_lines")))
  {
    formatter.setMaxCodeLength( wxAtoi(cfg->Read(_T("/max_line_length"))) );
    formatter.setBreakAfterMode(cfg->ReadBool(_T("/break_after_mode")));
  }
  else
    formatter.setMaxCodeLength(INT_MAX);

  formatter.setBreakBlocksMode(cfg->ReadBool(_T("/break_blocks")));
  formatter.setBreakClosingHeaderBlocksMode(cfg->ReadBool(_T("/break_blocks_all")));
  formatter.setOperatorPaddingMode(cfg->ReadBool(_T("/pad_operators")));
  formatter.setParensOutsidePaddingMode(cfg->ReadBool(_T("/pad_parentheses_out")));
  formatter.setParensInsidePaddingMode(cfg->ReadBool(_T("/pad_parentheses_in")));
  formatter.setParensFirstPaddingMode(cfg->ReadBool(_T("/pad_first_paren_out")));
  formatter.setParensHeaderPaddingMode(cfg->ReadBool(_T("/pad_header")));
  formatter.setParensUnPaddingMode(cfg->ReadBool(_T("/unpad_parentheses")));
  formatter.setCommaPaddingMode(cfg->ReadBool(_T("/pad_comma")));
  formatter.setDeleteEmptyLinesMode(cfg->ReadBool(_T("/delete_empty_lines")));
  formatter.setEmptyLineFill(cfg->ReadBool(_T("/fill_empty_lines")));

  wxString pointerAlign = cfg->Read(_T("/pointer_align"));
  if      (pointerAlign == _T("Type"))
    formatter.setPointerAlignment(astyle::PTR_ALIGN_TYPE);
  else if (pointerAlign == _T("Middle"))
    formatter.setPointerAlignment(astyle::PTR_ALIGN_MIDDLE);
  else if (pointerAlign == _T("Name"))
    formatter.setPointerAlignment(astyle::PTR_ALIGN_NAME);
  else
    formatter.setPointerAlignment(astyle::PTR_ALIGN_NONE);

  wxString referenceAlign = cfg->Read(_T("/reference_align"));
  if      (referenceAlign == _T("Type"))
    formatter.setReferenceAlignment(astyle::REF_ALIGN_TYPE);
  else if (referenceAlign == _T("Middle"))
    formatter.setReferenceAlignment(astyle::REF_ALIGN_MIDDLE);
  else if (referenceAlign == _T("Name"))
    formatter.setReferenceAlignment(astyle::REF_ALIGN_NAME);
  else
    formatter.setReferenceAlignment(astyle::REF_ALIGN_NONE);
}
void DlgFormatterSettings::ApplyTo(astyle::ASFormatter& formatter)
{
    // NOTE: Keep this in sync with FormatterSettings::ApplyTo
    if      (XRCCTRL(*m_dlg, "rbAllman", wxRadioButton)->GetValue())
        formatter.setFormattingStyle(astyle::STYLE_ALLMAN);
    else if (XRCCTRL(*m_dlg, "rbJava", wxRadioButton)->GetValue())
        formatter.setFormattingStyle(astyle::STYLE_JAVA);
    else if (XRCCTRL(*m_dlg, "rbKr", wxRadioButton)->GetValue())
        formatter.setFormattingStyle(astyle::STYLE_KR);
    else if (XRCCTRL(*m_dlg, "rbStroustrup", wxRadioButton)->GetValue())
        formatter.setFormattingStyle(astyle::STYLE_STROUSTRUP);
    else if (XRCCTRL(*m_dlg, "rbWhitesmith", wxRadioButton)->GetValue())
        formatter.setFormattingStyle(astyle::STYLE_WHITESMITH);
    else if (XRCCTRL(*m_dlg, "rbBanner", wxRadioButton)->GetValue())
        formatter.setFormattingStyle(astyle::STYLE_BANNER);
    else if (XRCCTRL(*m_dlg, "rbGNU", wxRadioButton)->GetValue())
        formatter.setFormattingStyle(astyle::STYLE_GNU);
    else if (XRCCTRL(*m_dlg, "rbLinux", wxRadioButton)->GetValue())
        formatter.setFormattingStyle(astyle::STYLE_LINUX);
    else if (XRCCTRL(*m_dlg, "rbHorstmann", wxRadioButton)->GetValue())
        formatter.setFormattingStyle(astyle::STYLE_HORSTMANN);
    else if (XRCCTRL(*m_dlg, "rb1TBS", wxRadioButton)->GetValue())
        formatter.setFormattingStyle(astyle::STYLE_1TBS);
    else if (XRCCTRL(*m_dlg, "rbPico", wxRadioButton)->GetValue())
        formatter.setFormattingStyle(astyle::STYLE_PICO);
    else if (XRCCTRL(*m_dlg, "rbLisp", wxRadioButton)->GetValue())
        formatter.setFormattingStyle(astyle::STYLE_LISP);

    bool value = XRCCTRL(*m_dlg, "chkForceUseTabs", wxCheckBox)->GetValue();
    int spaceNum = XRCCTRL(*m_dlg, "spnIndentation", wxSpinCtrl)->GetValue();

    if (XRCCTRL(*m_dlg, "chkUseTab", wxCheckBox)->GetValue())
        formatter.setTabIndentation(spaceNum, value);
    else
        formatter.setSpaceIndentation(spaceNum);

    formatter.setClassIndent(XRCCTRL(*m_dlg, "chkIndentClasses",                 wxCheckBox)->GetValue());
    formatter.setSwitchIndent(XRCCTRL(*m_dlg, "chkIndentSwitches",               wxCheckBox)->GetValue());
    formatter.setCaseIndent(XRCCTRL(*m_dlg, "chkIndentCase",                     wxCheckBox)->GetValue());
    formatter.setBracketIndent(XRCCTRL(*m_dlg, "chkIndentBrackets",              wxCheckBox)->GetValue());
    formatter.setBlockIndent(XRCCTRL(*m_dlg, "chkIndentBlocks",                  wxCheckBox)->GetValue());
    formatter.setNamespaceIndent(XRCCTRL(*m_dlg, "chkIndentNamespaces",          wxCheckBox)->GetValue());
    formatter.setLabelIndent(XRCCTRL(*m_dlg, "chkIndentLabels",                  wxCheckBox)->GetValue());
    formatter.setPreprocessorIndent(XRCCTRL(*m_dlg, "chkIndentPreprocessor",     wxCheckBox)->GetValue());
    formatter.setIndentCol1CommentsMode(XRCCTRL(*m_dlg, "chkIndentCol1Comments", wxCheckBox)->GetValue());

    wxString pointerAlign = XRCCTRL(*m_dlg, "cmbPointerAlign", wxComboBox)->GetValue();

    if (pointerAlign == _T("Type"))
        formatter.setPointerAlignment(astyle::PTR_ALIGN_TYPE);
    else if (pointerAlign == _T("Middle"))
        formatter.setPointerAlignment(astyle::PTR_ALIGN_MIDDLE);
    else if (pointerAlign == _T("Name"))
        formatter.setPointerAlignment(astyle::PTR_ALIGN_NAME);
    else
        formatter.setPointerAlignment(astyle::PTR_ALIGN_NONE);

    formatter.setBreakClosingHeaderBracketsMode(XRCCTRL(*m_dlg, "chkBreakClosing", wxCheckBox)->GetValue());
    formatter.setBreakBlocksMode(XRCCTRL(*m_dlg, "chkBreakBlocks",                 wxCheckBox)->GetValue());
    formatter.setBreakElseIfsMode(XRCCTRL(*m_dlg, "chkBreakElseIfs",               wxCheckBox)->GetValue());
    formatter.setOperatorPaddingMode(XRCCTRL(*m_dlg, "chkPadOperators",            wxCheckBox)->GetValue());
    formatter.setParensOutsidePaddingMode(XRCCTRL(*m_dlg, "chkPadParensOut",       wxCheckBox)->GetValue());
    formatter.setParensInsidePaddingMode(XRCCTRL(*m_dlg, "chkPadParensIn",         wxCheckBox)->GetValue());
    formatter.setParensUnPaddingMode(XRCCTRL(*m_dlg, "chkUnpadParens",             wxCheckBox)->GetValue());
    formatter.setSingleStatementsMode(!XRCCTRL(*m_dlg, "chkKeepComplex",           wxCheckBox)->GetValue());
    formatter.setBreakOneLineBlocksMode(!XRCCTRL(*m_dlg, "chkKeepBlocks",          wxCheckBox)->GetValue());
    formatter.setTabSpaceConversionMode(XRCCTRL(*m_dlg, "chkConvertTabs",          wxCheckBox)->GetValue());
    formatter.setEmptyLineFill(XRCCTRL(*m_dlg, "chkFillEmptyLines",                wxCheckBox)->GetValue());
    formatter.setAddBracketsMode(XRCCTRL(*m_dlg, "chkAddBrackets",                 wxCheckBox)->GetValue());
}