⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 windentdlg.h

📁 代码格式化工具。 其实就是linux下indent的windows版本。
💻 H
字号:
// windentDlg.h : 头文件
//

#pragma once
//#include "settingsheet.h"
#include "afxcmn.h"
#include "threedlg.h"
#include <map>
#include <string>
#include <iostream>
#include <fstream>
#include "saveasdlg.h"
#include "fileindentpage.h"
#include "strindentpage.h"
// CWindentDlg 对话框
class CWindentDlg : public CDialog
{
// 构造
public:
	CWindentDlg(CWnd* pParent = NULL);	// 标准构造函数

// 对话框数据
	enum { IDD = IDD_WINDENT_DIALOG };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV 支持

	std::map<std::string,user_options_ty> setting_map;
// 实现
protected:
	HICON m_hIcon;
	//CSettingSheet m_sheet;
	// 生成的消息映射函数
	virtual BOOL OnInitDialog();
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	DECLARE_MESSAGE_MAP()
public:
	afx_msg void OnBnClickedTest();
//	virtual BOOL Create(LPCTSTR lpszTemplateName, CWnd* pParentWnd = NULL);
//	afx_msg void OnBnClickedButton1();
	CTabCtrl m_tab;
	CStdPage m_StdPage;
	CIndPage m_IndPage;
	CBlkPage m_BlkPage;
	CFileIndentPage m_FilePage;
	CStrIndentPage  m_StrPage;
	user_options_ty setting;
	afx_msg void OnTcnSelchangeSetting(NMHDR *pNMHDR, LRESULT *pResult);
	void SaveSetting()
	{
		using namespace std;
		ofstream fout("setting.ini");
		map<string,user_options_ty>::const_iterator cit;
		for (cit=setting_map.begin();cit!=setting_map.end();++cit)
		{
			int * st=(int*)&cit->second;
			fout << '[' << cit->first << ']' << endl;
			for (int i=0;i<sizeof(user_options_ty)/sizeof(int);++i)
				fout << st[i]<<' ';
			fout<<endl;
		}
	}
	void OpenSetting()
	{
		using namespace std;
		setting_map.clear();
		ifstream fin("setting.ini");
		if (!fin)
		{
			indent_string("",0);
			setting = get_setting();
			setting_map.insert( make_pair(string("default"),setting) );
			SaveSetting();
			fin.open("setting.ini");
			if (!fin) return;
		}
		while(fin)
		{
			string title,line;
			user_options_ty current_setting;
			int i;
			int* st=(int*) &current_setting;
			//read title
			while(1)
			{
				if (!fin) return;
				getline(fin,title);
				// convert "   [xxx]   " to "xxx"
				size_t first=title.find_first_of('[');
				size_t last=title.find_last_of(']');
				if (first!=string::npos && 
					last!=string::npos  &&
					first < last
					)
				{
					title=title.substr(first+1,last-first-1);
					if (title!="") break;	//find a title;
				}
			}// loop for find title like "[xxx]"
			
			//read setting like "0 0  1 2 3 4", number sperate by space
			for (i=0;fin && i<sizeof(user_options_ty)/sizeof(int);++i)
			{
				fin>>st[i];
			}
			setting_map.insert( make_pair(title,current_setting) );
		}
	}
	user_options_ty* GetSetting()
	{
		m_StdPage.FillSetting(&setting);
		m_IndPage.FillSetting(&setting);
		m_BlkPage.FillSetting(&setting);
		return &setting;
	}
	afx_msg void OnCbnSelchangeSettinglist();
	afx_msg void OnBnClickedSave();
	afx_msg void OnTcnSelchangeIndentsheet(NMHDR *pNMHDR, LRESULT *pResult);
};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -