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

📄 configoptions.hpp

📁 j2me is based on j2mepolish, client & server for mobile application.
💻 HPP
字号:

//         Copyright E骾n O'Callaghan 2006 - 2008.
// Distributed under the Boost Software License, Version 1.0.
//    (See accompanying file LICENSE_1_0.txt or copy at
//          http://www.boost.org/LICENSE_1_0.txt)

#pragma once

#include "StdAfx.hpp"

#include "DdxEx.hpp"

class AboutOptions :
    public WTL::CPropertyPageImpl<AboutOptions>,
	public WTL::CDialogResize<AboutOptions>
{
	typedef AboutOptions thisClass;
	typedef WTL::CDialogResize<thisClass> resizeClass;

public:
    enum { IDD = IDD_ABOUT };

    BEGIN_MSG_MAP_EX(thisClass)
		MSG_WM_INITDIALOG(OnInitDialog)
		CHAIN_MSG_MAP(resizeClass)
        CHAIN_MSG_MAP(CPropertyPageImpl<thisClass>)
    END_MSG_MAP()

    BEGIN_DLGRESIZE_MAP(thisClass)
		DLGRESIZE_CONTROL(IDC_RICHEDITABOUT, DLSZ_SIZE_X|DLSZ_SIZE_Y)
		DLGRESIZE_CONTROL(IDC_ABOUT_VERSION, DLSZ_MOVE_X|DLSZ_MOVE_Y)
	END_DLGRESIZE_MAP()

    BOOL OnInitDialog (HWND hwndFocus, LPARAM lParam)
	{
		rich_edit_.Attach(GetDlgItem(IDC_RICHEDITABOUT));

		std::pair<void*, size_t> res = aux::app.res_find_lock(IDR_ABOUT_TEXT, RTF_RES_TYPE);

		std::string rtf(static_cast<char*>(res.first), res.second);
		std::wstring wrtf = aux::from_utf8_safe(rtf);

		rich_edit_.SendMessage(WM_SETTEXT, 0, (LPARAM)wrtf.c_str());
		rich_edit_.SetSelNone();
//		richEdit_.SetEventMask(ENM_REQUESTRESIZE);

        resizeClass::DlgResize_Init(false, true, WS_CLIPCHILDREN);

		return true;
	}

private:
	WTL::CRichEditCtrl rich_edit_;
	RECT richRect_;
};

class SettingsOptions :
    public WTL::CPropertyPageImpl<SettingsOptions>,
	public ATL::CAutoSizeWindow<SettingsOptions, false>,
    public CWinDataExchangeEx<SettingsOptions>
{
	typedef SettingsOptions thisClass;
	typedef ATL::CAutoSizeWindow<thisClass, false> autosizeClass;

public:
	SettingsOptions(std::wstring& user_profile_dir) :
		user_profile_dir_(user_profile_dir)
	{}

    enum { IDD = IDD_SETTINGS };

    BEGIN_MSG_MAP_EX(thisClass)
		MSG_WM_INITDIALOG(OnInitDialog)
		COMMAND_ID_HANDLER_EX(IDC_PRODIR_BROWSE, onFolderBrowse)

		CHAIN_MSG_MAP(autosizeClass)
        CHAIN_MSG_MAP(CPropertyPageImpl<thisClass>)
    END_MSG_MAP()

    BEGIN_DDX_MAP(RemoteOptions)
		DDX_EX_STDWSTRING(IDC_PRODIR, user_profile_dir_);
    END_DDX_MAP()

#define DIRECTORIES_LAYOUT \
	WMB_HEAD(WMB_COL(_gap), WMB_COLNOMAX(_exp), WMB_COLNOMAX(_auto), WMB_COL(_gap)),\
		WMB_ROW(_gap|3,	IDC_DIR_GROUP, _r, _r, _r), \
		WMB_ROW(_auto,	_d, IDC_PRODIR_TEXT, _r), \
		WMB_ROW(_auto,	_d, IDC_PRODIR, IDC_PRODIR_BROWSE), \
		WMB_ROW(_gap,	_d), \
	WMB_END()

	BEGIN_WINDOW_MAP(SettingsOptions, 6, 6, 3, 3)
		WMB_HEAD(WMB_COLNOMAX(_exp)), 
			WMB_ROW(_auto, DIRECTORIES_LAYOUT),
		WMB_END() 
	END_WINDOW_MAP()	

    BOOL OnInitDialog (HWND hwndFocus, LPARAM lParam)
	{
		DoDataExchange(false);
		return true;
	}

	void onFolderBrowse(UINT, int, HWND hWnd)
	{		
		WTL::CFolderDialog fldDlg (NULL, L"Chose a folder for user profiles.",
			BIF_RETURNONLYFSDIRS|BIF_NEWDIALOGSTYLE);

		if (IDOK == fldDlg.DoModal())
			SetDlgItemText(IDC_PRODIR, fldDlg.m_szFolderPath);
	}

	int OnApply()
	{
		return DoDataExchange(true);
	}

private:
	std::wstring& user_profile_dir_;
};

class ConfigOptionsProp :
	public WTL::CPropertySheet,
	public WTL::CDialogResize<ConfigOptionsProp>
{
	typedef ConfigOptionsProp thisClass;
	typedef WTL::CDialogResize<thisClass> resizeClass;

public:
    ConfigOptionsProp(std::wstring& user_profile_dir, LPCTSTR title = (LPCTSTR)NULL,
			UINT uStartPage = 0, HWND hWndParent = NULL) :
		WTL::CPropertySheet(title, uStartPage, hWndParent),
		centered_(false),
		settings_options_(user_profile_dir)
    {
		AddPage(settings_options_);
		AddPage(about_options);
    }

    BEGIN_MSG_MAP_EX(ConfigOptionsProp)
        MESSAGE_HANDLER(WM_SHOWWINDOW, OnShowWindow)
		MSG_WM_SIZE(OnSize)
		CHAIN_MSG_MAP(resizeClass)
        CHAIN_MSG_MAP(CPropertySheet)
    END_MSG_MAP()

    BEGIN_DLGRESIZE_MAP(thisClass)
		DLGRESIZE_CONTROL(0x3020, DLSZ_SIZE_X|DLSZ_SIZE_Y)

		DLGRESIZE_CONTROL(0x1, DLSZ_MOVE_X|DLSZ_MOVE_Y)
		DLGRESIZE_CONTROL(0x2, DLSZ_MOVE_X|DLSZ_MOVE_Y)
		DLGRESIZE_CONTROL(0x3021, DLSZ_MOVE_X|DLSZ_MOVE_Y)
	END_DLGRESIZE_MAP()

	void OnSize(UINT, WTL::CSize)
	{
        SetMsgHandled(false);

        HWND propTabs = GetDlgItem(0x3020);

		RECT rect;
		::GetWindowRect(propTabs, &rect);

		::MapWindowPoints(NULL, m_hWnd, (LPPOINT)&rect, 2);
		::SendMessage(propTabs, TCM_ADJUSTRECT, false, (LPARAM)&rect);

		::MoveWindow(GetActivePage(), rect.left, rect.top,
            rect.right-rect.left, rect.bottom-rect.top, true);
	}

    LRESULT OnShowWindow(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled)
    {
        if (wParam == TRUE)
        {
            WTL::CMenuHandle pSysMenu = GetSystemMenu(FALSE);

        	if (pSysMenu != NULL)
                pSysMenu.InsertMenu(-1, MF_BYPOSITION|MF_STRING, SC_SIZE, L"&Size");

            ModifyStyle(0, WS_THICKFRAME, 0);
            Center();

            resizeClass::DlgResize_Init(false, true, WS_CLIPCHILDREN);
        }
		
		bHandled = FALSE;
		
        return 0;
    }

    void Center(void)
    {
        if (!centered_)
        {
            CenterWindow();
            centered_ = true;
        }
    }

private:
    bool centered_;

	SettingsOptions settings_options_;
	AboutOptions about_options;

};

⌨️ 快捷键说明

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