/* * Copyright (C) tfs, 2007 * * This software is provided 'as-is', without any express or implied * warranty. In no event will the authors be held liable for any damages * arising from the use of this software. */ #include "stdafx.h" #include #include "UnisSample.h" #include "ChildView.h" #ifdef _DEBUG #define new DEBUG_NEW #endif #define COMPILE_VER 3 // CChildView CChildView::CChildView() { } CChildView::~CChildView() { } BEGIN_MESSAGE_MAP(CChildView, CWnd) ON_WM_PAINT() ON_COMMAND(ID_VIEW_JP78, OnViewJp78) ON_COMMAND(ID_VIEW_JP83, OnViewJp83) ON_COMMAND(ID_VIEW_JP90, OnViewJp90) ON_COMMAND(ID_VIEW_JP04, OnViewJp04) ON_UPDATE_COMMAND_UI(ID_VIEW_JP78, OnUpdateViewJp78) ON_UPDATE_COMMAND_UI(ID_VIEW_JP83, OnUpdateViewJp83) ON_UPDATE_COMMAND_UI(ID_VIEW_JP90, OnUpdateViewJp90) ON_UPDATE_COMMAND_UI(ID_VIEW_JP04, OnUpdateViewJp04) ON_COMMAND(ID_VIEW_FONT, OnViewFont) END_MESSAGE_MAP() /* * */ BOOL CChildView::PreCreateWindow(CREATESTRUCT& cs) { if (!CWnd::PreCreateWindow(cs)) return FALSE; cs.dwExStyle |= WS_EX_CLIENTEDGE; cs.style &= ~WS_BORDER; cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS, ::LoadCursor(NULL, IDC_ARROW), reinterpret_cast(COLOR_WINDOW+1), NULL); md = ID_VIEW_JP04; memset(&lf, '\0', sizeof(lf)); strcpy(lf.lfFaceName, _T("MS Gothic")); lf.lfHeight = -14; return TRUE; } /* * Verion 1 * Using ScriptStringXxxx. * feature tag is unavilable. */ #if COMPILE_VER == 1 void CChildView::OnPaint() { CPaintDC dc(this); SCRIPT_STRING_ANALYSIS ssa; int x = 0, y = 0; RECT rct = {0, 0, 100, 100}; HRESULT rslt; const char *str = "A‚ BC‚¢DE‚¤FG‚¦"; int len = strlen(str); rslt = ScriptStringAnalyse( dc.m_hDC, str, len, 2 * len + 16, DEFAULT_CHARSET, SSA_GLYPHS|SSA_LINK, 0, NULL, // control NULL, // state NULL, // piDx NULL, NULL, // pbInClass &ssa); rslt = ScriptStringOut( ssa, x, y, 0,//ETO_OPAQUE &rct, 0, 0, FALSE); ScriptStringFree(&ssa); } #endif /* * Version 2 * Using ScriptXxxxx * Still not using feature tag */ #if COMPILE_VER == 2 void CChildView::OnPaint() { CPaintDC dc(this); CFont ff; // ff.CreatePointFont(120, _T("MS Gothic"), NULL); ff.CreateFontIndirect(&lf); dc.SelectObject(ff); HRESULT rslt; const WCHAR *str = L"A’ÒBC‚¢DE‚¤FG‚¦"; // const WCHAR *str = L"ABCDEFG"; int len = (int)wcslen(str); const SCRIPT_CONTROL *psControl = NULL; const SCRIPT_STATE *psState = NULL; int cMaxItems = 500; SCRIPT_ITEM items[500]; int cItems; if (0) { // It does not seem these are required. SCRIPT_DIGITSUBSTITUTE sds = {0}; SCRIPT_CONTROL sc = {0}; SCRIPT_STATE ss = {0}; rslt = ScriptRecordDigitSubstitution(LOCALE_USER_DEFAULT, &sds); ScriptApplyDigitSubstitution(&sds, &sc, &ss); } /* Itemize */ rslt = ScriptItemize( str, len, cMaxItems, psControl, psState, items, &cItems); SCRIPT_CACHE ssc = NULL; int dx=0, dy=0; for (int i=0; iSetCheck((md == ID_VIEW_JP04)); } void CChildView::OnUpdateViewJp90(CCmdUI *pCmdUI) { pCmdUI->SetCheck((md == ID_VIEW_JP90)); } void CChildView::OnUpdateViewJp83(CCmdUI *pCmdUI) { pCmdUI->SetCheck((md == ID_VIEW_JP83)); } void CChildView::OnUpdateViewJp78(CCmdUI *pCmdUI) { pCmdUI->SetCheck((md == ID_VIEW_JP78)); } /* * Callback of font selectoin */ void CChildView::OnViewFont() { CFontDialog dlg; dlg.m_cf.Flags |= CF_INITTOLOGFONTSTRUCT; dlg.m_cf.lpLogFont = &lf; if (dlg.DoModal() != IDOK) return; lf = dlg.m_lf; Invalidate(); }