MainFrm.cpp

C:\home\SVGCats_src\src\MainFrm.cpp

[大目次 | 目次 | 関数 | マクロ]

大目次

目次

関数一覧

マクロ一覧


   1|// MainFrm.cpp : CMainFrame クラスの動作の定義を行います。 
   2|//
   3|
   4|#include "mixer_precomp.h"
   5|
   6|#ifdef  USES_MXP_AUTOINC
   7| #include  "SVGCat.ah"
   8|#endif
   9|
  10|#include <afxole.h>
  11|#include "direct.h"
  12|
  13|#ifdef _DEBUG
  14|#define new DEBUG_NEW
  15|#undef THIS_FILE
  16|static char THIS_FILE[] = __FILE__;
  17|#endif
  18|
  19|/////////////////////////////////////////////////////////////////////////////
  20|// CMainFrame
  21|
  22|IMPLEMENT_DYNAMIC(CMainFrame, CFrameWnd)
  23|
  24|BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
  25|    //{{AFX_MSG_MAP(CMainFrame)
  26|    ON_WM_CREATE()
  27|    ON_WM_CLOSE()
  28|    ON_WM_SETFOCUS()
  29|    ON_COMMAND(ID_SelectMulti, OnSelectMulti)
  30|    ON_COMMAND(ID_New, OnNew)
  31|    ON_COMMAND(ID_Open, OnOpen)
  32|    ON_COMMAND(ID_SaveOv, OnSaveOv)
  33|    ON_UPDATE_COMMAND_UI(ID_SaveOv, OnUpdateSaveOv)
  34|    ON_COMMAND(ID_SaveAs, OnSaveAs)
  35|    ON_COMMAND(ID_Recent1, OnRecent1)
  36|    ON_COMMAND(ID_Recent2, OnRecent2)
  37|    ON_COMMAND(ID_Recent3, OnRecent3)
  38|    ON_COMMAND(ID_Recent4, OnRecent4)
  39|    ON_COMMAND(ID_LowerPath, OnLowerPath)
  40|    ON_UPDATE_COMMAND_UI(ID_LowerPath, OnUpdateLowerPath)
  41|    ON_COMMAND(ID_BackupInterval, OnBackupInterval)
  42|    ON_WM_TIMER()
  43|    ON_COMMAND(ID_CreateTextParal, OnCreateTextParal)
  44|    ON_UPDATE_COMMAND_UI(ID_EDIT_UNDO, OnUpdateEditUndo)
  45|    ON_UPDATE_COMMAND_UI(ID_EDIT_REDO, OnUpdateEditRedo)
  46|    ON_COMMAND(ID_EDIT_CUT, OnEditCut)
  47|    ON_COMMAND(ID_EDIT_COPY, OnEditCopy)
  48|    ON_COMMAND(ID_EDIT_PASTE, OnEditPaste)
  49|    ON_UPDATE_COMMAND_UI(ID_EDIT_CUT, OnUpdateEditCut)
  50|    ON_UPDATE_COMMAND_UI(ID_EDIT_COPY, OnUpdateEditCopy)
  51|    ON_UPDATE_COMMAND_UI(ID_EDIT_PASTE, OnUpdateEditPaste)
  52|    ON_UPDATE_COMMAND_UI(ID_DEL, OnUpdateDel)
  53|    ON_UPDATE_COMMAND_UI(ID_ZBottom, OnUpdateZBottom)
  54|    ON_UPDATE_COMMAND_UI(ID_ZDown, OnUpdateZDown)
  55|    ON_UPDATE_COMMAND_UI(ID_ZTop, OnUpdateZTop)
  56|    ON_UPDATE_COMMAND_UI(ID_ZUp, OnUpdateZUp)
  57|    ON_UPDATE_COMMAND_UI(ID_PrimDown, OnUpdatePrimDown)
  58|    ON_UPDATE_COMMAND_UI(ID_PrimLeft, OnUpdatePrimLeft)
  59|    ON_UPDATE_COMMAND_UI(ID_PrimRight, OnUpdatePrimRight)
  60|    ON_UPDATE_COMMAND_UI(ID_PrimUp, OnUpdatePrimUp)
  61|    ON_COMMAND(ID_SingleClick, OnSingleClick)
  62|    ON_UPDATE_COMMAND_UI(ID_SingleClick, OnUpdateSingleClick)
  63|    ON_COMMAND(ID_WindowColor, OnWindowColor)
  64|    ON_UPDATE_COMMAND_UI(ID_WindowColor, OnUpdateWindowColor)
  65|    ON_UPDATE_COMMAND_UI(ID_Zoom100, OnUpdateZoom100)
  66|    ON_UPDATE_COMMAND_UI(ID_Zoom200, OnUpdateZoom200)
  67|    ON_UPDATE_COMMAND_UI(ID_Zoom400, OnUpdateZoom400)
  68|    ON_UPDATE_COMMAND_UI(ID_Zoom800, OnUpdateZoom800)
  69|    ON_UPDATE_COMMAND_UI(ID_ZoomWhole, OnUpdateZoomWhole)
  70|    ON_UPDATE_COMMAND_UI(ID_ZoomWidth, OnUpdateZoomWidth)
  71|    ON_COMMAND(ID_Preview, OnPreview)
  72|    ON_COMMAND(ID_ViewPropBar, OnViewPropBar)
  73|    ON_UPDATE_COMMAND_UI(ID_ViewPropBar, OnUpdateViewPropBar)
  74|    ON_COMMAND(ID_HELP, OnHelp)
  75|    ON_COMMAND(ID_HelpSample, OnHelpSample)
  76|    ON_COMMAND(ID_HelpSVG, OnHelpSVG)
  77|    ON_COMMAND(ID_DispHTML, OnDispHTML)
  78|    ON_WM_MOVE()
  79|    ON_COMMAND(ID_CreateBar, OnCreateBar)
  80|    ON_UPDATE_COMMAND_UI(ID_CreateBar, OnUpdateCreateBar)
  81|    ON_COMMAND(ID_Select, OnSelect)
  82|    ON_COMMAND(ID_Rotate, OnRotate)
  83|    ON_COMMAND(ID_CreateText, OnCreateText)
  84|    ON_COMMAND(ID_CreateTextBox, OnCreateTextBox)
  85|    ON_COMMAND(ID_CreateTextCircle, OnCreateTextCircle)
  86|    ON_COMMAND(ID_CreateTextDiamond, OnCreateTextDiamond)
  87|    ON_COMMAND(ID_CreateTextRound, OnCreateTextRound)
  88|    ON_COMMAND(ID_CreateImage2, OnCreateImage2)
  89|    ON_COMMAND(ID_CreateLine, OnCreateLine)
  90|    ON_COMMAND(ID_CreateArrow, OnCreateArrow)
  91|    ON_COMMAND(ID_CreateLineCorner, OnCreateLineCorner)
  92|    ON_COMMAND(ID_CreateRect, OnCreateRect)
  93|    ON_COMMAND(ID_CreateCircle, OnCreateCircle)
  94|    ON_COMMAND(ID_CreateTransCircle, OnCreateTransCircle)
  95|    ON_COMMAND(ID_CreateDiamond, OnCreateDiamond)
  96|    ON_COMMAND(ID_CreateRoundRect, OnCreateRoundRect)
  97|    ON_COMMAND(ID_CreateGuideLine, OnCreateGuideLine)
  98|    ON_COMMAND(ID_Ink, OnInk)
  99|    ON_COMMAND(ID_RedInk, OnRedInk)
 100|    ON_COMMAND(ID_Marker, OnMarker)
 101|    ON_COMMAND(ID_BlueInk, OnBlueInk)
 102|    ON_COMMAND(ID_RedMarker, OnRedMarker)
 103|    ON_COMMAND(ID_YellowMarker, OnYellowMarker)
 104|    ON_COMMAND(ID_Rope, OnRope)
 105|    ON_COMMAND(ID_Eraser, OnEraser)
 106|    ON_COMMAND(ID_AlignBar, OnAlignBar)
 107|    ON_UPDATE_COMMAND_UI(ID_AlignBar, OnUpdateAlignBar)
 108|    ON_COMMAND(ID_AlignIntervalHorizontal, OnAlignIntervalHorizontal)
 109|    ON_COMMAND(ID_AlignIntervalVertical, OnAlignIntervalVertical)
 110|    ON_COMMAND(ID_AlignHorizontal, OnAlignHorizontal)
 111|    ON_COMMAND(ID_AlignVertical, OnAlignVertical)
 112|    ON_COMMAND(ID_AlignLeft, OnAlignLeft)
 113|    ON_COMMAND(ID_AlignRight, OnAlignRight)
 114|    ON_COMMAND(ID_AlignTop, OnAlignTop)
 115|    ON_COMMAND(ID_AlignBottom, OnAlignBottom)
 116|    ON_COMMAND(ID_FitSizeHorizontal, OnFitSizeHorizontal)
 117|    ON_COMMAND(ID_FitSizeVertical, OnFitSizeVertical)
 118|    ON_UPDATE_COMMAND_UI(ID_AlignBottom, OnUpdateAlignBottom)
 119|    ON_UPDATE_COMMAND_UI(ID_AlignHorizontal, OnUpdateAlignHorizontal)
 120|    ON_UPDATE_COMMAND_UI(ID_AlignIntervalHorizontal, OnUpdateAlignIntervalHorizontal)
 121|    ON_UPDATE_COMMAND_UI(ID_AlignIntervalVertical, OnUpdateAlignIntervalVertical)
 122|    ON_UPDATE_COMMAND_UI(ID_AlignLeft, OnUpdateAlignLeft)
 123|    ON_UPDATE_COMMAND_UI(ID_AlignRight, OnUpdateAlignRight)
 124|    ON_UPDATE_COMMAND_UI(ID_AlignTop, OnUpdateAlignTop)
 125|    ON_UPDATE_COMMAND_UI(ID_AlignVertical, OnUpdateAlignVertical)
 126|    ON_UPDATE_COMMAND_UI(ID_FitSizeHorizontal, OnUpdateFitSizeHorizontal)
 127|    ON_UPDATE_COMMAND_UI(ID_FitSizeVertical, OnUpdateFitSizeVertical)
 128|    ON_COMMAND(ID_NextPage, OnNextPage)
 129|    ON_UPDATE_COMMAND_UI(ID_NextPage, OnUpdateNextPage)
 130|    ON_COMMAND(ID_PrevPage, OnPrevPage)
 131|    ON_UPDATE_COMMAND_UI(ID_PrevPage, OnUpdatePrevPage)
 132|    ON_COMMAND(ID_FirstPage, OnFirstPage)
 133|    ON_COMMAND(ID_LastPage, OnLastPage)
 134|    ON_COMMAND(ID_NewPage, OnNewPage)
 135|    ON_COMMAND(ID_MakeBackPage, OnMakeBackPage)
 136|    ON_UPDATE_COMMAND_UI(ID_MakeBackPage, OnUpdateMakeBackPage)
 137|    ON_COMMAND(ID_CreateRedText, OnCreateRedText)
 138|    ON_COMMAND(ID_CreateBlueText, OnCreateBlueText)
 139|    ON_COMMAND(ID_PenBar, OnPenBar)
 140|    ON_UPDATE_COMMAND_UI(ID_PenBar, OnUpdatePenBar)
 141|    ON_COMMAND(ID_TaskTray, OnTaskTray)
 142|    ON_UPDATE_COMMAND_UI(ID_TaskTray, OnUpdateTaskTray)
 143|    ON_COMMAND(ID_Updsk, OnUpdsk)
 144|    ON_UPDATE_COMMAND_UI(ID_Updsk, OnUpdateUpdsk)
 145|    ON_COMMAND(ID_AutoSave, OnAutoSave)
 146|    ON_UPDATE_COMMAND_UI(ID_AutoSave, OnUpdateAutoSave)
 147|    ON_UPDATE_COMMAND_UI(ID_LastPage, OnUpdateLastPage)
 148|    ON_UPDATE_COMMAND_UI(ID_FirstPage, OnUpdateFirstPage)
 149|    ON_COMMAND(ID_SaveHtml, OnSaveHtml)
 150|    ON_COMMAND(ID_Recent5, OnRecent5)
 151|    ON_COMMAND(ID_Recent6, OnRecent6)
 152|    ON_COMMAND(ID_Recent7, OnRecent7)
 153|    ON_COMMAND(ID_Recent8, OnRecent8)
 154|    ON_COMMAND(ID_DelIcon, OnDelIcon)
 155|    ON_UPDATE_COMMAND_UI(ID_NewPage, OnUpdateNewPage)
 156|    ON_COMMAND(ID_NewChildPage, OnNewChildPage)
 157|    ON_UPDATE_COMMAND_UI(ID_NewChildPage, OnUpdateNewChildPage)
 158|    ON_COMMAND(ID_SideByTree, OnSideByTree)
 159|    ON_COMMAND(ID_MaxTree, OnMaxTree)
 160|    ON_COMMAND(ID_DelPage, OnDelPage)
 161|    ON_UPDATE_COMMAND_UI(ID_DelPage, OnUpdateDelPage)
 162|    ON_UPDATE_COMMAND_UI(ID_SideByTree, OnUpdateSideByTree)
 163|    ON_COMMAND(ID_OpenBackup, OnOpenBackup)
 164|    ON_COMMAND(ID_ThrowToTrash, OnThrowToTrash)
 165|    ON_COMMAND(ID_RenameOrMove, OnRenameOrMove)
 166|    ON_COMMAND(ID_NewPrevPage, OnNewPrevPage)
 167|    ON_UPDATE_COMMAND_UI(ID_NewPrevPage, OnUpdateNewPrevPage)
 168|    ON_COMMAND(ID_ReadDefDesign, OnReadDefDesign)
 169|    ON_COMMAND(ID_OpenDesign, OnOpenDesign)
 170|    ON_COMMAND(ID_ReadCustomDesign, OnReadCustomDesign)
 171|    ON_COMMAND(ID_ResetDesign, OnResetDesign)
 172|    ON_COMMAND(ID_Find, OnFind)
 173|    ON_COMMAND(ID_FindNext, OnFindNext)
 174|    ON_COMMAND(ID_FindBack, OnFindBack)
 175|    ON_COMMAND(ID_NewWindow, OnNewWindow)
 176|    ON_UPDATE_COMMAND_UI(ID_MaxTree, OnUpdateMaxTree)
 177|    ON_UPDATE_COMMAND_UI(ID_FindNext, OnUpdateFindNext)
 178|    ON_UPDATE_COMMAND_UI(ID_FindBack, OnUpdateFindBack)
 179|    ON_COMMAND(ID_PasteTimeStamp, OnPasteTimeStamp)
 180|    ON_COMMAND(ID_CreateTimeStamp, OnCreateTimeStamp)
 181|    ON_UPDATE_COMMAND_UI(ID_CreateTimeStamp, OnUpdateCreateTimeStamp)
 182|    ON_COMMAND(ID_EditPageTitle, OnEditPageTitle)
 183|    ON_COMMAND(ID_CopyStyle, OnCopyStyle)
 184|    ON_COMMAND(ID_PasteStyle, OnPasteStyle)
 185|    ON_UPDATE_COMMAND_UI(ID_PasteStyle, OnUpdatePasteStyle)
 186|    ON_UPDATE_COMMAND_UI(ID_CopyStyle, OnUpdateCopyStyle)
 187|    ON_UPDATE_COMMAND_UI(ID_Ink, OnUpdateInk)
 188|    ON_UPDATE_COMMAND_UI(ID_RedInk, OnUpdateRedInk)
 189|    ON_UPDATE_COMMAND_UI(ID_RedMarker, OnUpdateRedMarker)
 190|    ON_UPDATE_COMMAND_UI(ID_BlueInk, OnUpdateBlueInk)
 191|    ON_UPDATE_COMMAND_UI(ID_Marker, OnUpdateMarker)
 192|    ON_UPDATE_COMMAND_UI(ID_YellowMarker, OnUpdateYellowMarker)
 193|    ON_UPDATE_COMMAND_UI(ID_Rope, OnUpdateRope)
 194|    ON_UPDATE_COMMAND_UI(ID_Eraser, OnUpdateEraser)
 195|    ON_COMMAND(ID_OpenLink, OnOpenLink)
 196|    ON_UPDATE_COMMAND_UI(ID_OpenLink, OnUpdateOpenLink)
 197|    ON_COMMAND(ID_OpenCommercial, OnOpenCommercial)
 198|    ON_COMMAND(ID_InputLicense, OnInputLicense)
 199|	ON_COMMAND(ID_ImportSVG, OnImportSVG)
 200|	ON_COMMAND(ID_SaveAsReadOnly, OnSaveAsReadOnly)
 201|	ON_COMMAND(ID_SaveImage, OnSaveImage)
 202|	ON_UPDATE_COMMAND_UI(ID_SaveImage, OnUpdateSaveImage)
 203|	ON_WM_DRAWCLIPBOARD()
 204|	ON_WM_QUERYENDSESSION()
 205|	ON_WM_ACTIVATE()
 206|	ON_COMMAND(ID_OpenTemplate, OnOpenTemplate)
 207|	ON_COMMAND(ID_SaveTemplate, OnSaveTemplate)
 208|	ON_COMMAND(ID_SaveForMail, OnSaveForMail)
 209|	ON_WM_CHANGECBCHAIN()
 210|	ON_COMMAND(ID_Capture, OnCapture)
 211|	ON_COMMAND(ID_CreateMatome, OnCreateMatome)
 212|	ON_COMMAND(ID_ViewMode, OnViewMode)
 213|	ON_UPDATE_COMMAND_UI(ID_ViewMode, OnUpdateViewMode)
 214|	ON_WM_SYSCOMMAND()
 215|	ON_COMMAND(ID_Reload, OnReload)
 216|	ON_COMMAND(ID_CloseTaskTray, OnCloseTaskTray)
 217|	ON_COMMAND(ID_SaveAsImage, OnSaveAsImage)
 218|	ON_COMMAND(ID_ScopeMode, OnScopeMode)
 219|	ON_UPDATE_COMMAND_UI(ID_ScopeMode, OnUpdateScopeMode)
 220|	ON_WM_SYSCOLORCHANGE()
 221|	ON_WM_GETMINMAXINFO()
 222|	ON_WM_SIZE()
 223|	//}}AFX_MSG_MAP
 224|    ON_LBN_DBLCLK(IDC_Propertys, OnDblClickProp)
 225|    ON_LBN_SETFOCUS(IDC_Propertys, OnSetFocusProp)
 226|    ON_WM_DROPFILES()
 227|END_MESSAGE_MAP()
 228|
 229|/////////////////////////////////////////////////////////////////////////////
 230|// CMainFrame クラスの構築/消滅
 231|
 232|static char*  _svg_read_filter=  "SVG形式 Scalable Vector Graphics (*.svg, *.svgz)|*.svg;*.svgz|すべてのファイル (*.*)|*.*||";
 233|static char*  _svg_read_filterE= "SVG format  Scalable Vector Graphics (*.svg, *.svgz)|*.svg;*.svgz|All Files (*.*)|*.*||";
 234|static char*  _svg_write_filter= "SVG形式 Scalable Vector Graphics (*.svg)|*.svg|圧縮 SVG形式 Scalable Vector Graphics (*.svgz)|*.svgz|すべてのファイル (*.*)|*.*||";
 235|static char*  _svg_write_filterE="SVG format  Scalable Vector Graphics (*.svg)|*.svg|compressed SVG format  Scalable Vector Graphics (*.svgz)|*.svgz|All Files (*.*)|*.*||";
 236|static char*  _jpg_filter=  "JPEG 画像形式 (*.jpg)|*.jpg;*.jpeg|すべてのファイル (*.*)|*.*||";
 237|static char*  _jpg_filterE= "JPEG Image format (*.jpg)|*.jpg;*.jpeg|All Files (*.*)|*.*||";
 238|static char*  _png_filter=  "PNG 画像形式 (*.png)|*.png|すべてのファイル (*.*)|*.*||";
 239|static char*  _png_filterE= "PNG Image format (*.png)|*.png|All Files (*.*)|*.*||";
 240|static char*  _gif_filter=  "GIF 画像形式 (*.gif)|*.gif|すべてのファイル (*.*)|*.*||";
 241|static char*  _gif_filterE= "GIF Image format (*.gif)|*.gif|All Files (*.*)|*.*||";
 242|static char*  _any_filter=  "すべてのファイル (*.*)|*.*||";
 243|static char*  _any_filterE= "All Files (*.*)|*.*||";
 244|static char*  _img2_filter=  "PNG形式 (*.png)|*.png|JPEG形式 (*.jpg)|*.jpg;*.jpeg||";
 245|static char*  _img2_filterE= "PNG format (*.png)|*.png|JPEG format (*.jpg)|*.jpg;*.jpeg||";
 246|#define  _design_path  "system\\design"
 247|#define  _template_path "system\\template"
 248|
 249|
 250|
 251|CMainFrame::CMainFrame()
 252|{
 253|  // TODO: この位置にメンバの初期化処理コードを追加してください。
 254|//  m_wndView = new CChildView;
 255|  m_bHide = false;
 256|  m_bViewMode = false;
 257|  m_bVisiblePropBeforeHideToolBars = true;
 258|  m_bOriginalWindowZoomed = FALSE;
 259|  m_bScopeMode = false;
 260|  m_bScopeHiding = false;
 261|  m_bScopeHidingCancel = false;
 262|  m_bScopeHide = false;
 263|  m_ScopeWindowRect.left = 300;  m_ScopeWindowRect.right = 900;
 264|  m_ScopeWindowRect.top = 30;  m_ScopeWindowRect.bottom = 200;
 265|  m_bScopeWindowZoomed = FALSE;
 266|  m_FileUpdateNotify = NULL;
 267|
 268|  m_PropBarDisp = true;
 269|  m_PropBarX = -200;  m_PropBarY = 80;
 270|  m_PropBarIsFloat = true;
 271|  m_PropBarStyle = 0;
 272|
 273|  m_KWord = "";
 274|  m_FoundPrim = NULL;
 275|  m_WM_TaskbarRestart = 0;
 276|
 277|  m_ClipPageNum = -1;
 278|  m_PasteCount = 0;
 279|
 280|  m_TextDesign = NULL;
 281|  m_TextRectDesign = NULL;
 282|  m_TextCircleDesign = NULL;
 283|  m_TextRoundRectDesign = NULL;
 284|  m_TextDiamondDesign = NULL;
 285|  m_TextParallelDesign = NULL;
 286|  m_LineDesign = NULL;
 287|  m_ArrowDesign = NULL;
 288|  m_CorneredLineDesign = NULL;
 289|  m_GuideLineTextDesign = NULL;
 290|  m_GuideLineArrowDesign = NULL;
 291|  m_RectDesign = NULL;
 292|  m_CircleDesign = NULL;
 293|  m_RoundRectDesign = NULL;
 294|  m_DiamondDesign = NULL;
 295|  m_RedTextDesign = NULL;
 296|  m_BlueTextDesign = NULL;
 297|  m_TimeStampDesign = NULL;
 298|  m_StrongerDesign = NULL;
 299|
 300|  m_VisibleOnTray =
 301|     CMainFrame_Visible_MainToolBar |
 302|     CMainFrame_Visible_CreateBar |
 303|     CMainFrame_Visible_AlignBar |
 304|     CMainFrame_Visible_PenBar;
 305|}
 306|
 307|CMainFrame::~CMainFrame()
 308|{
 309|}
 310|
 311|
 312| 
 313|/***********************************************************************
 314|  1. <<< [CMainFrame::OnCreate] ウィンドウを生成したときの処理 >>> 
 315|************************************************************************/
 316|int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
 317|{
 318|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
 319|  int  mainFrame = ( app->m_bJapanese ? IDR_MAINFRAME : IDR_MAINFRAME_E );
 320|  int  createBar = ( app->m_bJapanese ? IDR_CreateBar : IDR_CreateBar_E );
 321|  int  alignBar = ( app->m_bJapanese ? IDR_AlignBar : IDR_AlignBar_E );
 322|  int  penBar = ( app->m_bJapanese ? IDR_PenBar : IDR_PenBar_E );
 323|  bool  bParentHide = ( ( app->m_nCmdShow & (SW_MINIMIZE | SW_HIDE) ) != 0 );
 324|  DWORD  visibleFlag = ! bParentHide ? WS_VISIBLE : 0;
 325|
 326|  m_AppIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
 327|  m_MainMenu.LoadMenu( IDR_MAINFRAME );
 328|  m_IconMenu = GetSubMenu( LoadMenu( app->m_hInstance,
 329|    app->m_bJapanese ? MAKEINTRESOURCE(IDR_IconRight) : MAKEINTRESOURCE(IDR_IconRight_E) ), 0 );
 330|  strcpy( m_FolderPathOnOpen, WinX_getMyDocPath() );
 331|  m_bInTray = false;
 332|  m_bActivated = true;
 333|  m_bMouseActivated = false;
 334|
 335|  if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
 336|    return -1;
 337|
 338|  m_DisableOnSetFocusProp = false;
 339|
 340|  // フレームのクライアント領域全体を占めるビューを作成します。
 341|#if 0  /*   m_wndView = (CChildView*)m_wndSplitter.GetPane( 0, 1 ); に移動した */
 342|  if (!m_wndView->Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,
 343|    CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL))
 344|  {
 345|    TRACE0("Failed to create view window\n");
 346|    return -1;
 347|  }
 348|#endif
 349|
 350|  // ドッキングツールバーを作成します
 351|  EnableDocking(CBRS_ALIGN_ANY);
 352|
 353|  if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_ALIGN_TOP
 354|    | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
 355|    !m_wndToolBar.LoadToolBar(mainFrame))
 356|  {
 357|    TRACE0("Failed to create toolbar\n");
 358|    return -1;      // 作成に失敗
 359|  }
 360|  m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
 361|  DockControlBar(&m_wndToolBar);
 362|
 363|  if (!m_CreateBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_ALIGN_LEFT
 364|    | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
 365|    !m_CreateBar.LoadToolBar(createBar))
 366|  {
 367|    TRACE0("Failed to create toolbar\n");
 368|    return -1;      // 作成に失敗
 369|  }
 370|  //m_CreateBar.MoveWindow( 400, 0, 400, 32 );
 371|  m_CreateBar.EnableDocking(CBRS_ALIGN_ANY);
 372|  DockControlBar(&m_CreateBar);
 373|
 374|
 375|  // プロパティ・バーを表示する
 376|  m_DisableOnSetFocusProp = true;
 377|  m_PropBar.Create( this, IDD_PropBar,
 378|      WS_CHILD | CBRS_GRIPPER | SS_NOTIFY | CBRS_SIZE_DYNAMIC,
 379|      AFX_IDW_TOOLBAR, TRUE, !bParentHide );
 380|  m_DisableOnSetFocusProp = false;
 381|  m_PropBar.SetWindowText( app->m_bJapanese ? "プロパティ" : "Property" );
 382|  m_PropBar.EnableDocking( CBRS_ALIGN_LEFT | CBRS_ALIGN_RIGHT, false );
 383|  m_PropBar.SetVisible( m_PropBarDisp );
 384|
 385|
 386|  if (!m_AlignBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_ALIGN_BOTTOM
 387|    | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
 388|    !m_AlignBar.LoadToolBar(alignBar))
 389|  {
 390|    TRACE0("Failed to create toolbar\n");
 391|    return -1;      // 作成に失敗
 392|  }
 393|
 394|  m_AlignBar.EnableDocking(CBRS_ALIGN_ANY);
 395|  DockControlBar(&m_AlignBar);
 396|
 397|  if (!m_PenBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_ALIGN_RIGHT
 398|    | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
 399|    !m_PenBar.LoadToolBar(penBar))
 400|  {
 401|    TRACE0("Failed to create toolbar\n");
 402|    return -1;      // 作成に失敗
 403|  }
 404|  m_PenBar.EnableDocking(CBRS_ALIGN_ANY);
 405|  DockControlBar(&m_PenBar);
 406|
 407|  SetIcon( m_AppIcon, TRUE );      // 大きいアイコンを設定
 408|  SetIcon( m_AppIcon, FALSE );    // 小さいアイコンを設定
 409|
 410|  {
 411|    CMenu* sysMenu = GetSystemMenu(FALSE);
 412|    sysMenu->AppendMenu( MF_SEPARATOR );
 413|    sysMenu->AppendMenu( MF_STRING, ID_ViewMode, "ビューア・モード(&V)\tV" );
 414|    #ifdef  SVGCats_ScopeMode
 415|      sysMenu->AppendMenu( MF_STRING, ID_ScopeMode, "スコープ・モード(&E)\tE" );
 416|    #endif
 417|  }
 418|
 419|  OleInitialize( NULL );
 420|
 421|  ListX_init( &m_PropPrims );
 422|  ResetProp();
 423|  m_PropBar.SetMenu( NULL );
 424|  SetFocus();  // フォーカスを親ウィンドウにする
 425|  m_NextClipChain = ::SetClipboardViewer(m_hWnd);
 426|
 427|  CListBox*  list = (CListBox*)m_PropBar.GetDlgItem( IDC_Propertys );
 428|  list->SetLocale( app->m_bJapanese ? 0x0411 : 0x0409 );
 429|
 430|  /* ウィンドウの表示を更新する */
 431|  UpdateWindowText();
 432|  SetRecentFileMenu();
 433|
 434|  DragAcceptFiles();
 435|
 436|
 437|  /* タスクトレイを使うための準備をする */
 438|  m_WM_TaskbarRestart = RegisterWindowMessage( TEXT("TaskbarCreated") );
 439|  if ( app->m_bTaskTray )  AddToTaskTray();
 440|
 441|  return 0;
 442|}
 443|
 444|
 445|
 446|void  CMainFrame::UpdateWindowText()
 447|{
 448|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
 449|  CString  page;
 450|
 451|  if ( app->m_file.m_CurrentPageNum == 0 ) {
 452|    page.Format( app->m_bJapanese ? "背景ページ" : "Background Page" );
 453|  }
 454|  else {
 455|    page.Format( app->m_bJapanese ? "%d/%d ページ目" : "Page %d/%d",
 456|      app->m_file.m_CurrentPageNum,
 457|      ListX_getN( &app->m_file.m_pages, SVGCat_Page ) + app->m_file.m_StartPageNum - 1 );
 458|  }
 459|
 460|  if ( app->m_path[0] == '\0' ) {
 461|    if ( app->m_bJapanese )
 462|      SetWindowText( CString("無題 - ") + page + " - " SVGCats_AppName );
 463|    else
 464|      SetWindowText( CString("NoTitle - ") + page + " - " SVGCats_AppName );
 465|  }
 466|  else
 467|    SetWindowText( CString( StrX_refFName(app->m_path) ) + " - " + page + " - " SVGCats_AppName );
 468|
 469|
 470|  /* タスクトレイで表示するパスを再設定する */
 471|  if ( app->m_bTaskTray ) {
 472|    NOTIFYICONDATA  notif;
 473|    HICON  myIcon;
 474|    char  path[_MAX_PATH];
 475|
 476|
 477|    /* 表示するアイコンをロードする */
 478|    if ( app->m_path[0] == '\0' && app->m_bNewTaskTray ) {
 479|      StrX_getExeFullPath( path, "system\\icon\\new.ico", sizeof(path) );
 480|    }
 481|    else {
 482|      app->GetDisplayFName( path );
 483|      StrX_ins( path, "system\\icon\\" );
 484|      StrX_getExeFullPath( path, path, sizeof(path) );
 485|      StrX_chgExt( path, "ico" );
 486|    }
 487|    if ( (int)ExtractIconEx( path, 0, NULL, &myIcon, 1 ) <= 0 )
 488|      myIcon = m_AppIcon;
 489|
 490|    app->GetDisplayFName( path );
 491|
 492|    notif.cbSize = sizeof(NOTIFYICONDATA);
 493|    notif.hWnd = m_hWnd;
 494|    notif.uID = (UINT)m_hWnd;  /* ウィンドウごとに識別する */
 495|    notif.uFlags = NIF_TIP;
 496|    notif.hIcon = myIcon;
 497|    strncpy( notif.szTip, CString("デジタルスクラップブック SVG Cats 2 - ") + path,
 498|      sizeof(notif.szTip)-1 );
 499|    notif.szTip[sizeof(notif.szTip)-1] = '\0';
 500|
 501|    Shell_NotifyIcon( NIM_MODIFY, &notif );
 502|  }
 503|}
 504|
 505|
 506|
 507|BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
 508|{
 509|  if( !CFrameWnd::PreCreateWindow(cs) )
 510|    return FALSE;
 511|  // TODO: この位置で CREATESTRUCT cs を修正して、Window クラスやスタイルを
 512|  //       修正してください。
 513|
 514|  cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
 515|  cs.lpszClass = AfxRegisterWndClass(0);
 516|  return TRUE;
 517|}
 518|
 519|
 520| 
 521|BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) 
 522|{
 523|  // 分割ウィンドウを作成します
 524|  // このコードは、AppWizard の「Windowsエクスプローラスタイル」で出力されたものを参考にしています。
 525|  if (!m_wndSplitter.CreateStatic(this, 1, 2))
 526|    return FALSE;
 527|
 528|  if (!m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CLeftView), CSize(100, 100), pContext))
 529|    return FALSE;
 530|  if (!m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CChildView), CSize(100, 100), pContext))
 531|    {  m_wndSplitter.DestroyWindow();  return FALSE; }
 532|
 533|  m_Left = (CLeftView*)m_wndSplitter.GetPane( 0, 0 );
 534|  m_wndView = (CChildView*)m_wndSplitter.GetPane( 0, 1 );
 535|
 536|  {
 537|    CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
 538|    CTreeCtrl*  tree;
 539|
 540|    tree = &m_Left->GetTreeCtrl();
 541|    SetWindowLong( tree->m_hWnd, GWL_STYLE,
 542|      GetWindowLong( tree->m_hWnd, GWL_STYLE ) | TVS_HASLINES | TVS_LINESATROOT |
 543|      TVS_SHOWSELALWAYS | TVS_HASBUTTONS );
 544|    m_wndSplitter.SetColumnInfo( 0, 0, 0 );  app->m_SplitMode = 1;
 545|    m_wndSplitter.RecalcLayout();
 546|  }
 547|
 548|
 549|  /* ツリーのイメージリストを作成する */
 550|  {
 551|    CBitmap  bitmap;
 552|    CTreeCtrl*  tree = &m_Left->GetTreeCtrl();
 553|
 554|    // イメージリストの初期化
 555|    // 4番目の引数はリストが保持するイメージの数。5番目はリストを拡張するときの拡張イメージ数
 556|    m_ImageList = new CImageList;
 557|    m_ImageList->Create( 16, 16, ILC_MASK, 1, 0 );
 558|
 559|    // ビットマップイメージをイメージリストに追加する
 560|    // Add関数の2番目の引数は透過色(マスク)を表す
 561|    bitmap.LoadBitmap(IDB_BITMAP1);
 562|    m_ImageList->Add(&bitmap, RGB(0,0xFF,0));
 563|    bitmap.DeleteObject();
 564|
 565|    // ツリーコントロールにイメージリストを設定
 566|    tree->SetImageList(m_ImageList, TVSIL_NORMAL);
 567|  }
 568|
 569|
 570|  return CFrameWnd::OnCreateClient(lpcs, pContext);
 571|}
 572|
 573|
 574| 
 575|/***********************************************************************
 576|  2. <<< [CMainFrame::ResetAttr] マウスのモードをリセットする >>> 
 577|************************************************************************/
 578|void  CMainFrame::ResetAttr()
 579|{
 580|  CInputML::m_ID_prev = NULL;
 581|  CInputML1::m_ID_prev = NULL;
 582|
 583|  #ifdef  USES_InkOverlay
 584|  {
 585|    TabletHardwareCapabilities  cap;
 586|    IInkTablet*  tablet;
 587|    HRESULT   hr;
 588|    int  nRetry = 0;
 589|
 590|    if ( m_wndView->m_InkTablets != NULL ) {
 591|      for (;;) {
 592|        hr = m_wndView->m_InkTablets->get_DefaultTablet( &tablet );
 593|        if ( hr == 0 )  break;
 594|        if ( hr == TPC_E_NO_DEFAULT_TABLET ) return;
 595|
 596|        Sleep(2000);
 597|        nRetry++;  /* スタートアップにあるとき、時々エラーになるためリトライ */
 598|        if ( nRetry > 10 )  error();
 599|      }
 600|
 601|      hr = tablet->get_HardwareCapabilities( &cap );
 602|      if ( hr != 0 )  error();
 603|    }
 604|
 605|    if ( m_wndView->m_InkTablets != NULL &&  (cap & THWC_Integrated) ) {
 606|      m_mode = CMainFrame_UseInk;
 607|      OnInk();
 608|      m_wndView->m_bFirstCreate = false;
 609|    }
 610|    else {
 611|      m_mode = CMainFrame_CreateTextBox;
 612|      UpdateCreateToolBar( ID_CreateTextBox, &m_CreateBar, false );
 613|      // UpdateCreateToolBar( ID_CreateTextBox, &m_PenBar, false );
 614|      m_wndView->m_bFirstCreate = false;
 615|    }
 616|
 617|    if ( m_wndView->m_InkOverlay != NULL ) {
 618|      hr = m_wndView->m_InkOverlay->put_Enabled(
 619|        (cap & THWC_Integrated) ? VARIANT_TRUE : VARIANT_FALSE );
 620|      if ( hr != 0 )  error();
 621|    }
 622|
 623|    if ( m_wndView->m_InkTablets != NULL ) {
 624|      hr = tablet->Release();  tablet = NULL;
 625|      if ( hr > 5 )  error();
 626|    }
 627|
 628|  }
 629|
 630|  #else
 631|    m_mode = CMainFrame_CreateTextBox;
 632|    m_bStrongCreate = false;
 633|    OnCreateText();
 634|  #endif
 635|}
 636|
 637|
 638| 
 639|/***********************************************************************
 640|  3. <<< [CMainFrame::OnClose] ウィンドウを閉じるボタンを押したときの処理 >>> 
 641|************************************************************************/
 642|#define  CMainFrame_LoadOnClose
 643|
 644|void CMainFrame::OnClose()
 645|{
 646|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
 647|  CString  s;
 648|
 649|  if ( m_Timer != 0 )  { KillTimer( m_Timer );  m_Timer = 0; }
 650|
 651|  /* ファイルに保存する */
 652|  m_PropBar.SyncXY();
 653|  app->SaveSVGCatsIni();
 654|
 655|  if ( m_wndView->IsDirty() ) {
 656|    int  r;
 657|
 658|    if ( app->m_bAutoSave ) {
 659|      r = IDYES;
 660|    }
 661|    else {
 662|      if ( app->m_bJapanese )  s.LoadString( IDS_SaveConfirm );
 663|      else  s.LoadString( IDS_SaveConfirm_E );
 664|
 665|      ::SetWindowPos( m_hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE );
 666|      ::SetWindowPos( m_hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE );
 667|      ::SetWindowPos( m_hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE );
 668|      ::SetFocus( m_hWnd );
 669|      r = MessageBox( s, app->m_path, MB_YESNOCANCEL | MB_ICONWARNING );
 670|    }
 671|
 672|    switch ( r ) {
 673|     case  IDYES:
 674|       OnSaveOv();
 675|       if ( m_wndView->IsDirty() ) {
 676|         if ( app->m_BackupInterval > 0 )
 677|           m_Timer = SetTimer( CMainFrame_Timer_Backup, 60*1000*app->m_BackupInterval, NULL );
 678|         return;  /* キャンセルされた */
 679|       }
 680|       break;
 681|     case  IDCANCEL:
 682|       if ( app->m_BackupInterval > 0 )
 683|         m_Timer = SetTimer( CMainFrame_Timer_Backup, 60*1000*app->m_BackupInterval, NULL );
 684|       return;
 685|     case  IDNO:
 686|       if ( app->m_bTaskTray ) {
 687|         if ( app->m_path[0] == '\0' )  New();
 688|         else  Load( app->m_path, false );
 689|       }
 690|       break;
 691|    }
 692|  }
 693|
 694|  if ( app->m_path[0] != '\0' && ! app->m_bTaskTray )
 695|    app->SetRecentFile( app->m_path );
 696|
 697|
 698|  /* フォルダをロックしないように、カレントディレクトリをルートにする */
 699|  {
 700|    char*  drv = getenv( "SystemDrive" );
 701|
 702|    _chdir( "\\" );
 703|    if ( drv == NULL )  _chdrive( 'C' - 'A' + 1 );
 704|    else  _chdrive( drv[0] - 'A' + 1 );
 705|    _chdir( "\\" );
 706|  }
 707|
 708|  /* アプリケーションを終了する代わりに非表示にする */
 709|  if ( app->m_bTaskTray ) {
 710|    NOTIFYICONDATA  notif;
 711|    HICON  myIcon;
 712|    POINT  pt;
 713|    HRESULT  hr;
 714|    IInkRenderer*  render;
 715|    char  path[_MAX_PATH];
 716|
 717|    m_bInTray = true;
 718|    m_wndView->ResetSelect();
 719|
 720|    if ( m_wndView->m_InkOverlay != NULL ) {
 721|      pt.x = 0;  pt.y = 0;
 722|      m_wndView->ScrollToPosition( pt );
 723|      hr = m_wndView->m_InkOverlay->get_Renderer( &render );
 724|      if ( hr != 0 ) error();
 725|      hr = render->Move( m_wndView->m_prevX0, m_wndView->m_prevY0 );  /* PixelToInkSpace の基準座標を戻す */
 726|      if ( hr != 0 ) error();
 727|      hr = render->Release();  render = NULL;
 728|      m_wndView->m_prevX0 = 0;  m_wndView->m_prevY0 = 0;
 729|    }
 730|
 731|    if ( m_bViewMode )  OnViewMode();  /* ビューモードをやめる */
 732|    if ( m_bScopeMode )  OnScopeMode();  /* スコープモードをやめる */
 733|    HideWindow();
 734|    ResetAttr();
 735|    UpdateWindowText();
 736|    ChgPage( 1 );
 737|
 738|    if ( app->m_path[0] == '\0' && app->m_bNewTaskTray ) {
 739|      New();
 740|      StrX_getExeFullPath( path, "system\\icon\\new.ico", sizeof(path) );
 741|    }
 742|    else {
 743|      strcpy( path, app->m_path );
 744|      #ifndef  CMainFrame_LoadOnClose
 745|        New();
 746|      #else
 747|        if ( app->m_bNewTaskTray ) {
 748|          if ( ListX_getN( &app->m_file.m_prims, SVGCat_Page ) != 0 ||
 749|               m_wndView->GetStrokeCount() != 0 )
 750|            if ( ! app->m_bForTheFirstTime )  OnNewPrevPage();
 751|            app->Save( app->m_path, false );
 752|        }
 753|      #endif
 754|      strcpy( app->m_path, path );
 755|
 756|      app->GetDisplayFName( path );
 757|      StrX_ins( path, "system\\icon\\" );
 758|      StrX_getExeFullPath( path, path, sizeof(path) );
 759|      StrX_chgExt( path, "ico" );
 760|    }
 761|    #ifdef  CMainFrame_LoadOnClose
 762|      if ( FileX_isExist( app->m_path ) )
 763|        FileX_getUpdate( app->m_path, &m_TimeStampOnTmpClose );
 764|    #endif
 765|
 766|
 767|    if ( (int)ExtractIconEx( path, 0, NULL, &myIcon, 1 ) <= 0 )
 768|      myIcon = m_AppIcon;
 769|
 770|    app->GetDisplayFName( path );
 771|    notif.cbSize = sizeof(NOTIFYICONDATA);
 772|    notif.hWnd = m_hWnd;
 773|    notif.uID = (UINT)m_hWnd;  /* ウィンドウごとに識別する */
 774|    notif.uFlags = NIF_ICON | NIF_TIP;
 775|    notif.hIcon = myIcon;
 776|    strncpy( notif.szTip, CString("デジタルスクラップブック SVG Cats 2 - ") + path,
 777|      sizeof(notif.szTip)-1 );
 778|    notif.szTip[sizeof(notif.szTip)-1] = '\0';
 779|    Shell_NotifyIcon( NIM_MODIFY, &notif );
 780|
 781|    if ( app->m_bUpdsk )
 782|      SHChangeNotify( SHCNE_ASSOCCHANGED, SHCNF_FLUSH, NULL, NULL );
 783|
 784|    return;
 785|  }
 786|
 787|  ChangeClipboardChain( m_NextClipChain );
 788|
 789|  /* アプリケーションを終了する */
 790|  OnResetDesign();
 791|
 792|  ListX_toEmptyDelete( &m_PropPrims, ListX_ElemX, NULL );
 793|  remove( app->m_backPath );
 794|  delete  m_ImageList;
 795|
 796|  Errors_bExiting = true;
 797|  app->Finish();
 798|  m_wndView->OnClose2();
 799|  Errors_chkDefault();
 800|
 801|  CFrameWnd::OnClose();
 802|}
 803|
 804|
 805| 
 806|/***********************************************************************
 807|  4. <<< [CMainFrame::OnQueryEndSession] Windows を終了するときの処理 >>> 
 808|************************************************************************/
 809|BOOL CMainFrame::OnQueryEndSession()
 810|{
 811|  if (!CFrameWnd::OnQueryEndSession())
 812|    return FALSE;
 813|
 814|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
 815|  CString  s;
 816|
 817|  if ( m_Timer != 0 )  { KillTimer( m_Timer );  m_Timer = 0; }
 818|
 819|  /* ファイルに保存する */
 820|  app->SaveSVGCatsIni();
 821|
 822|  if ( m_wndView->IsDirty() ) {
 823|    int  r;
 824|
 825|    if ( app->m_bAutoSave ) {
 826|      r = IDYES;
 827|    }
 828|    else {
 829|      if ( app->m_bJapanese )  s.LoadString( IDS_SaveConfirm );
 830|      else  s.LoadString( IDS_SaveConfirm_E );
 831|
 832|      ::SetWindowPos( m_hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE );
 833|      r = MessageBox( s, app->m_path, MB_YESNOCANCEL | MB_ICONWARNING );
 834|    }
 835|
 836|    switch ( r ) {
 837|     case  IDYES:  OnSaveOv();
 838|       if ( m_wndView->IsDirty() )  goto  resume;  /* キャンセルされた */
 839|       break;
 840|     case  IDCANCEL:  goto  resume;
 841|    }
 842|  }
 843|  return  TRUE;
 844|
 845|resume:
 846|  if ( app->m_BackupInterval > 0 )
 847|    m_Timer = SetTimer( CMainFrame_Timer_Backup, 60*1000*app->m_BackupInterval, NULL );
 848|  else
 849|    m_Timer = 0;
 850|
 851|  return FALSE;
 852|}
 853| 
 854|/***********************************************************************
 855|  5. <<< [chgToMenuString] 履歴メニューに表示する内容を取得する >>> 
 856|************************************************************************/
 857|static void  chgToMenuString( char* menuStr, int menuStr_size,
 858|  const char* path, int num )
 859|{
 860|  int   i, len;
 861|  char*  fname = StrX_refFName( path );
 862|
 863|  menuStr[ menuStr_size - 1 ] = '\0';
 864|
 865|  /* ファイル名を格納する */
 866|  sprintf( menuStr, "(&%d) ", num );
 867|  strncpy( menuStr + 5, fname, menuStr_size - 6 );
 868|  len = strlen( menuStr );
 869|  if ( len + 6 >= menuStr_size ) {
 870|    if ( (int)strlen( fname ) > menuStr_size - 1 ) {
 871|      i = menuStr_size - 3;
 872|      menuStr[i] = '.';  i++;
 873|      menuStr[i] = '.';  i++;
 874|      menuStr[i] = '.';
 875|    }
 876|    return;
 877|  }
 878|
 879|  /* 続いてフルパスを格納する */
 880|  #if 0
 881|  strcat( menuStr, " (" );
 882|  strncpy( strchr( menuStr, '\0' ),  path,  menuStr_size - len - 3 - 1 );
 883|  len = strlen( menuStr );
 884|  if ( len >= menuStr_size - 3 ) {
 885|    i = menuStr_size - 4;
 886|    menuStr[i] = '.';  i++;
 887|    menuStr[i] = '.';  i++;
 888|    menuStr[i] = '.';
 889|  }
 890|  strcat( menuStr, ")" );
 891|  #endif
 892|}
 893| 
 894|/***********************************************************************
 895|  6. <<< [CMainFrame::DefWindowProc] 特殊なウィンドウメッセージに対する処理 >>> 
 896|************************************************************************/
 897|LRESULT CMainFrame::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
 898|{
 899|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
 900|
 901|  /* タスクトレイが再起動したときに、アイコンを再登録する */
 902|  if ( message == m_WM_TaskbarRestart && m_WM_TaskbarRestart != 0 ) {
 903|    if ( app->m_bTaskTray )  AddToTaskTray();
 904|  }
 905|
 906|  /* アイコンをクリックしたとき、開きなおして表示状態に戻す */
 907|  if ( message == WM_TRAYICONMESSAGE ) {
 908|
 909|    if ( lParam == WM_LBUTTONDOWN ) {
 910|      app->OpenCommercial2();
 911|      if ( m_bInTray ) {
 912|        m_bInTray = false;
 913|        RestoreWindow( true, NULL );
 914|      }
 915|      else {
 916|        if ( IsZoomed() )  ShowWindow( SW_SHOW );
 917|        else  ShowWindow( SW_RESTORE );
 918|        SetForegroundWindow();
 919|        m_PropBar.OnChgParentShow();
 920|        if ( app->m_bNewTaskTray )  OnNew();
 921|      }
 922|    }
 923|    if ( lParam == WM_RBUTTONUP ) {
 924|      CMenu   menu;
 925|      CMenu*  menu2;
 926|      POINT   pt;
 927|      int i,n;
 928|      char  menuStr[70];
 929|      enum { iMenu = 5, nMenu = 7 };
 930|      enum { mf_type = MF_BYPOSITION | MF_STRING };
 931|
 932|
 933|      app->OpenCommercial2();
 934|
 935|      /* ここでメニューを表示する前に ウィンドウをアクティブにしないと、*/
 936|      /* 右クリックメニューをキャンセルしたときに、次の右クリックメニューが出なくなる */
 937|      SetForegroundWindow();
 938|
 939|      /* これまでの履歴メニューを消す */
 940|      menu.Attach( m_IconMenu );
 941|      menu2 = &menu;
 942|      n = menu2->GetMenuItemCount();
 943|      for ( i = 0; i < n - nMenu; i++ )
 944|        menu2->RemoveMenu( iMenu, MF_BYPOSITION );
 945|
 946|      /* メニューを足す */
 947|      if ( app->m_nRecentPath >= 1 ) {
 948|        chgToMenuString( menuStr, sizeof(menuStr), app->m_RecentPath[0], 1 );
 949|        menu2->InsertMenu( iMenu, mf_type, ID_Recent1, menuStr );
 950|      }
 951|      if ( app->m_nRecentPath >= 2 ) {
 952|        chgToMenuString( menuStr, sizeof(menuStr), app->m_RecentPath[1], 2 );
 953|        menu2->InsertMenu( iMenu+1, mf_type, ID_Recent2, menuStr );
 954|      }
 955|      if ( app->m_nRecentPath >= 3 ) {
 956|        chgToMenuString( menuStr, sizeof(menuStr), app->m_RecentPath[2], 3 );
 957|        menu2->InsertMenu( iMenu+2, mf_type, ID_Recent3, menuStr );
 958|      }
 959|      if ( app->m_nRecentPath >= 4 ) {
 960|        chgToMenuString( menuStr, sizeof(menuStr), app->m_RecentPath[3], 4 );
 961|        menu2->InsertMenu( iMenu+3, mf_type, ID_Recent4, menuStr );
 962|      }
 963|      if ( app->m_nRecentPath >= 5 ) {
 964|        chgToMenuString( menuStr, sizeof(menuStr), app->m_RecentPath[4], 5 );
 965|        menu2->InsertMenu( iMenu+4, mf_type, ID_Recent5, menuStr );
 966|      }
 967|      if ( app->m_nRecentPath >= 6 ) {
 968|        chgToMenuString( menuStr, sizeof(menuStr), app->m_RecentPath[5], 6 );
 969|        menu2->InsertMenu( iMenu+5, mf_type, ID_Recent6, menuStr );
 970|      }
 971|      if ( app->m_nRecentPath >= 7 ) {
 972|        chgToMenuString( menuStr, sizeof(menuStr), app->m_RecentPath[6], 7 );
 973|        menu2->InsertMenu( iMenu+6, mf_type, ID_Recent7, menuStr );
 974|      }
 975|      if ( app->m_nRecentPath >= 8 ) {
 976|        chgToMenuString( menuStr, sizeof(menuStr), app->m_RecentPath[7], 8 );
 977|        menu2->InsertMenu( iMenu+7, mf_type, ID_Recent8, menuStr );
 978|      }
 979|
 980|      /* メニューを表示する */
 981|      GetCursorPos( &pt );
 982|      menu.TrackPopupMenu( TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RIGHTBUTTON,
 983|        pt.x, pt.y, this, NULL );
 984|
 985|      menu.Detach();
 986|    }
 987|  }
 988|
 989|  return  CFrameWnd::DefWindowProc(message, wParam, lParam);
 990|}
 991|
 992|
 993|BOOL  CMainFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
 994|{
 995|    // ビューに最初にコマンドを処理する機会を与えます。
 996|    if (m_wndView->OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
 997|        return TRUE;
 998|
 999|    // 処理されなかった場合にはデフォルトの処理を行います。
1000|    return CFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
1001|}
1002|
1003|
1004|int  CMainFrame::GetCadPrimMode()
1005|{
1006|  return  m_mode == CMainFrame_Rotate ?  CadPrim_RotateMode : CadPrim_ResizeMode;
1007|}
1008|
1009|
1010|void  CMainFrame::AddToTaskTray()
1011|{
1012|  /* タスクトレイにアイコンを登録する */
1013|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
1014|  NOTIFYICONDATA  notif;
1015|  HICON  myIcon;
1016|  char   path[_MAX_PATH];
1017|
1018|
1019|  /* 表示するアイコンをロードする */
1020|  if ( app->m_path[0] == '\0' && app->m_bNewTaskTray ) {
1021|    StrX_getExeFullPath( path, "system\\icon\\new.ico", sizeof(path) );
1022|  }
1023|  else {
1024|    app->GetDisplayFName( path );
1025|    StrX_ins( path, "system\\icon\\" );
1026|    StrX_getExeFullPath( path, path, sizeof(path) );
1027|    StrX_chgExt( path, "ico" );
1028|  }
1029|  if ( (int)ExtractIconEx( path, 0, NULL, &myIcon, 1 ) <= 0 )
1030|    myIcon = m_AppIcon;
1031|
1032|
1033|  /* アイコンの各種情報を設定する */
1034|  app->GetDisplayFName( path );
1035|
1036|  notif.cbSize = sizeof(NOTIFYICONDATA);
1037|  notif.hWnd = m_hWnd;
1038|  notif.uID = (UINT)m_hWnd;  /* ウィンドウごとに識別する */
1039|  notif.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
1040|  notif.uCallbackMessage = WM_TRAYICONMESSAGE;
1041|  notif.hIcon = myIcon;
1042|  strncpy( notif.szTip, CString("デジタルスクラップブック SVG Cats 2 - ") + path,
1043|    sizeof(notif.szTip)-1 );
1044|  notif.szTip[sizeof(notif.szTip)-1] = '\0';
1045|
1046|
1047|  /* アイコンを登録する */
1048|  Shell_NotifyIcon( NIM_ADD, &notif );
1049|}
1050|
1051|
1052|void  CMainFrame::RemoveFromTaskTray()
1053|{
1054|  /* タスクトレイからアイコンを削除する */
1055|  NOTIFYICONDATA notif;
1056|
1057|  notif.cbSize = sizeof(NOTIFYICONDATA);
1058|  notif.hWnd = m_hWnd;
1059|  notif.uID = (UINT)m_hWnd;
1060|  notif.uFlags = 0;
1061|
1062|  Shell_NotifyIcon( NIM_DELETE, &notif );
1063|}
1064|
1065|
1066|BOOL CMainFrame::OnCommand(WPARAM wParam, LPARAM lParam)
1067|{
1068|  switch ( wParam ) {
1069|    case  CMainFrame_Capture2:   OnCapture2();  break;
1070|    case  CMainFrame_Scrolling:  m_wndView->OnDragScrollTiming();  break;
1071|  }
1072|
1073|  m_bActivated = true;
1074|  m_bMouseActivated = false;
1075|
1076|	return CFrameWnd::OnCommand(wParam, lParam);
1077|}
1078|
1079|void CMainFrame::OnSysCommand(UINT nID, LPARAM lParam)
1080|{
1081|  if ( nID == ID_ViewMode )
1082|    OnViewMode();
1083|  else if ( nID == ID_ScopeMode )
1084|    OnScopeMode();
1085|
1086|	CFrameWnd::OnSysCommand(nID, lParam);
1087|}
1088|
1089| 
1090|/***********************************************************************
1091|  7. <<< [CMainFrame::HideWindow] ウィンドウを非表示状態にする >>> 
1092|************************************************************************/
1093|void CMainFrame::HideWindow()
1094|{
1095|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
1096|
1097|  if ( m_bHide )  return;
1098|
1099|  HideToolBars();
1100|
1101|  ShowWindow(SW_HIDE);
1102|  m_PropBar.OnChgParentShow();
1103|
1104|  m_bHide = true;
1105|}
1106|
1107|
1108|/***********************************************************************
1109|  8. <<< [CMainFrame::HideToolBars] ツールバーなどをすべてを非表示にする >>>
1110|************************************************************************/
1111|void CMainFrame::HideToolBars()
1112|{
1113|  m_PropBar.OnChgParentShow();
1114|
1115|  m_bVisiblePropBeforeHideToolBars = m_PropBar.GetVisible();
1116|  if ( m_bViewMode )  m_PropBar.SetVisible( false );
1117|
1118|  m_VisibleOnTray =
1119|    ( m_wndToolBar.IsWindowVisible() ?
1120|       CMainFrame_Visible_MainToolBar : 0 ) |
1121|    ( m_PropBar.IsWindowVisible() ?
1122|       CMainFrame_Visible_PropBar : 0 ) |
1123|    ( m_CreateBar.IsWindowVisible() ?
1124|       CMainFrame_Visible_CreateBar : 0 ) |
1125|    ( m_AlignBar.IsWindowVisible() ?
1126|       CMainFrame_Visible_AlignBar : 0 ) |
1127|    ( m_PenBar.IsWindowVisible() ?
1128|       CMainFrame_Visible_PenBar : 0 );
1129|
1130|  ShowControlBar( &m_wndToolBar, FALSE, FALSE );
1131|  ShowControlBar( &m_CreateBar, FALSE, FALSE );
1132|  ShowControlBar( &m_AlignBar, FALSE, FALSE );
1133|  ShowControlBar( &m_PenBar, FALSE, FALSE );
1134|}
1135| 
1136|void  CMainFrame_ShowWindowFunc( CMainFrame* m, bool bShow ) 
1137|{
1138|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
1139|  char  c = app->m_path[0];
1140|
1141|  app->m_path[0] = '\0';  /* 再ロードして m_HoldPrim をおかしくしないため */
1142|
1143|  if ( bShow )  m->RestoreWindow( false, NULL );
1144|  else  m->HideWindow();
1145|
1146|  app->m_path[0] = c;
1147|  m->UpdateWindowText();
1148|}
1149| 
1150|/***********************************************************************
1151|  9. <<< [CMainFrame::RestoreWindow] ウィンドウを非表示状態から戻す >>> 
1152|【引数】
1153|  ・char*  loadPath;  ロードする SVG ファイルパス、NULL=これまで開いていたファイル, ""=新規
1154|************************************************************************/
1155|void  CMainFrame::RestoreWindow( bool bOpenWindow, char* loadPath )
1156|{
1157|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
1158|  BOOL  visible = IsWindowVisible();
1159|
1160|  if ( ! m_bHide )  return;
1161|  m_bHide = false;
1162|
1163|  /* 表示状態を元に戻す */
1164|  if ( IsZoomed() )  ShowWindow( SW_SHOW );
1165|  else  ShowWindow( SW_RESTORE );
1166|  SetForegroundWindow();
1167|  if ( ! visible ) {
1168|    ShowToolBars();
1169|  }
1170|  CInputML::m_bImeOn = false;
1171|
1172|  if ( ! bOpenWindow )  return;
1173|
1174|
1175|  /* SVGファイルを読み込む */
1176|  if ( ! m_wndView->IsDirty() ) {
1177|    if ( loadPath == NULL ) {
1178|      if ( app->m_path[0] == '\0' ) {
1179|        NoTree();
1180|      }
1181|      else {
1182|        time_t  t;
1183|
1184|        #ifdef  CMainFrame_LoadOnClose
1185|          if ( FileX_isExist( app->m_path ) )  FileX_getUpdate( app->m_path, &t );
1186|          else  t = 0;
1187|        #else
1188|          t = 0;
1189|        #endif
1190|
1191|        if ( t != m_TimeStampOnTmpClose ) {
1192|          #ifdef  CMainFrame_LoadOnClose
1193|            char  path_back[_MAX_PATH];
1194|
1195|            strcpy( path_back, app->m_path );
1196|            New();
1197|            strcpy( app->m_path, path_back );
1198|          #endif
1199|          if ( FileX_isExist( app->m_path ) )
1200|            Load( app->m_path, ! app->m_bTaskTray );
1201|          else {
1202|            if ( app->m_bNewTaskTray ) {
1203|              char  path[_MAX_PATH];
1204|
1205|              StrX_getExeFullPath( path, "system\\new.svg", sizeof(path) );
1206|              FileX_copy( app->m_path, path );
1207|              Load( app->m_path, ! app->m_bTaskTray );
1208|            }
1209|            else {
1210|              MessageBox( CString(app->m_path) +
1211|                ( app->m_bJapanese ? " が見つかりません" : " not found" ) );
1212|              SendMessage( WM_CLOSE, 0, 0 );
1213|            }
1214|          }
1215|        }
1216|      }
1217|    }
1218|    else {
1219|      if ( m_wndView->IsDirty() ) {
1220|        int  r;
1221|        CString  s;
1222|
1223|        m_wndView->ResetSelect();
1224|
1225|        if ( app->m_bJapanese )  s.LoadString( IDS_SaveConfirm );
1226|        else  s.LoadString( IDS_SaveConfirm_E );
1227|
1228|        ::SetWindowPos( m_hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE );
1229|        r = MessageBox( s, app->m_path, MB_YESNOCANCEL | MB_ICONWARNING );
1230|        switch ( r ) {
1231|          case  IDYES:
1232|            OnSaveOv();
1233|          case  IDNO:
1234|            strcpy( app->m_path, loadPath );
1235|            if ( app->m_path[0] != '\0' )
1236|              Load( app->m_path, ! app->m_bTaskTray );
1237|          case  IDCANCEL:
1238|            break;
1239|        }
1240|      }
1241|      else {
1242|        strcpy( app->m_path, loadPath );
1243|        if ( app->m_path[0] != '\0' )
1244|          Load( app->m_path, ! app->m_bTaskTray );
1245|      }
1246|    }
1247|  }
1248|  if ( m_Timer == 0 ) {
1249|    if ( app->m_BackupInterval > 0 )
1250|      m_Timer = SetTimer( CMainFrame_Timer_Backup, 60*1000*app->m_BackupInterval, NULL );
1251|    else
1252|      m_Timer = 0;
1253|  }
1254|}
1255|
1256|
1257|/***********************************************************************
1258|  10. <<< [CMainFrame::ShowToolBars] ツールバーなどをすべてを表示する >>>
1259|************************************************************************/
1260|void  CMainFrame::ShowToolBars()
1261|{
1262|  ShowControlBar( &m_wndToolBar, m_VisibleOnTray & CMainFrame_Visible_MainToolBar, FALSE );
1263|  m_PropBar.OnChgParentShow();
1264|  m_PropBar.SetVisible( m_bVisiblePropBeforeHideToolBars );
1265|  ShowControlBar( &m_CreateBar, m_VisibleOnTray & CMainFrame_Visible_CreateBar, FALSE );
1266|  ShowControlBar( &m_AlignBar, m_VisibleOnTray & CMainFrame_Visible_AlignBar, FALSE );
1267|  ShowControlBar( &m_PenBar, m_VisibleOnTray & CMainFrame_Visible_PenBar, FALSE );
1268|}
1269| 
1270|/***********************************************************************
1271|  11. <<< [CMainFrame::OnDelIcon] タスクトレイのアイコンから終了を選んだときの処理 >>> 
1272|************************************************************************/
1273|void CMainFrame::OnDelIcon()
1274|{
1275|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
1276|
1277|  //this->SendMessage( WM_TRAYICONMESSAGE, 0, WM_LBUTTONDOWN );
1278|  New();
1279|  this->SendMessage( WM_COMMAND, ID_TaskTray, 0 );
1280|  this->SendMessage( WM_CLOSE, 0, 0 );
1281|}
1282|
1283|
1284| 
1285|/***********************************************************************
1286|  12. <<< [CMainFrame::OnMove] ウィンドウを動かしたときの処理 >>> 
1287|************************************************************************/
1288|void CMainFrame::OnMove(int x, int y)
1289|{
1290|  CFrameWnd::OnMove(x, y);
1291|  if ( Errors_bExiting )  return;
1292|
1293|  m_PropBar.OnParentMove( x, y );
1294|}
1295|
1296|
1297| 
1298|/////////////////////////////////////////////////////////////////////////////
1299|// CMainFrame クラスの診断 
1300|
1301|#ifdef _DEBUG
1302|void CMainFrame::AssertValid() const
1303|{
1304|  CFrameWnd::AssertValid();
1305|}
1306|
1307|void CMainFrame::Dump(CDumpContext& dc) const
1308|{
1309|  CFrameWnd::Dump(dc);
1310|}
1311|
1312|#endif //_DEBUG
1313|
1314|/////////////////////////////////////////////////////////////////////////////
1315|// CMainFrame メッセージ ハンドラ
1316|void CMainFrame::OnSetFocus(CWnd* pOldWnd)
1317|{
1318|  // ビュー ウィンドウにフォーカスを与えます。
1319|  m_wndView->SetFocus();
1320|}
1321|
1322|
1323| 
1324|/*-------------------------------------------------------------------------*/
1325|/* 13. <<<< ◆メニュー >>>>  */ 
1326|/*-------------------------------------------------------------------------*/
1327|
1328|
1329| 
1330|/***********************************************************************
1331|  13-1. <<< [CMainFrame::OnNew] 無地のページを選んだときの処理 >>> 
1332|************************************************************************/
1333|void CMainFrame::OnNew()
1334|{
1335|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
1336|  CString  s;
1337|
1338|  RestoreWindow( true, NULL );
1339|
1340|  ChgPage( 1 );
1341|  if ( ListX_getN( &app->m_file.m_prims, SVGCat_Page ) != 0 ||
1342|       m_wndView->GetStrokeCount() != 0 ) {
1343|    OnNewPrevPage();
1344|  }
1345|
1346|#if 0
1347|  if ( m_wndView->IsDirty() ) {
1348|    int  r;
1349|
1350|    if ( app->m_bJapanese )  s.LoadString( IDS_SaveConfirm );
1351|    else  s.LoadString( IDS_SaveConfirm_E );
1352|
1353|    ::SetWindowPos( m_hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE );
1354|    r = MessageBox( s, app->m_path, MB_YESNOCANCEL | MB_ICONWARNING );
1355|    switch ( r ) {
1356|     case  IDYES:  OnSaveOv();  break;
1357|     case  IDCANCEL:  return;
1358|    }
1359|  }
1360|
1361|  m_wndView->ResetSelect();
1362|  New();
1363|#endif
1364|}
1365|
1366|
1367| 
1368|/***********************************************************************
1369|  13-2. <<< [CMainFrame::New] キャンバスをクリアする >>> 
1370|************************************************************************/
1371|void  CMainFrame::New()
1372|{
1373|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
1374|  char  path[_MAX_PATH];
1375|
1376|  if ( m_hWnd != NULL ) {
1377|    m_wndView->OnFinishPrimMove();
1378|    m_wndView->ResetSelect();
1379|    m_wndView->ResetScrollAndScale();
1380|  }
1381|
1382|  if ( app->m_path[0] != '\0' && ! app->m_bTaskTray )
1383|    app->SetRecentFile( app->m_path );
1384|  app->m_path[0] = '\0';
1385|  if ( m_hWnd != NULL ) {
1386|    UpdateWindowText();
1387|  }
1388|  app->Finish();
1389|  app->NewEmpty();
1390|  m_wndView->NewInkOverlay();
1391|  m_PasteCount = 0;
1392|  m_wndView->m_TextCreateX = 30;
1393|  m_wndView->m_TextCreateY = 30;
1394|
1395|
1396|  /* ツリーを作り直す */
1397|  {
1398|    CTreeCtrl*  tree = &m_Left->GetTreeCtrl();
1399|    SVGCat_Page*  page;
1400|    HTREEITEM  item;
1401|
1402|    tree->DeleteAllItems();
1403|    page = ListX_getFirst( &app->m_file.m_pages, SVGCat_Page );
1404|    item = tree->InsertItem( "New Page" );
1405|    tree->SetItemData( item, (long)page );
1406|    tree->Select( tree->GetChildItem( TVI_ROOT ), TVGN_CARET );
1407|  }
1408|
1409|
1410|  /* バックアップファイルの名前も変える */
1411|  strcpy( path, app->m_backPath );
1412|  app->ChangeBackup();
1413|  MoveFile( path, app->m_backPath );
1414|
1415|
1416|  /* 表示を元に戻す */
1417|  m_wndView->m_Zoom = 100;
1418|  m_wndView->m_bBitmap = false;
1419|  if ( m_hWnd != NULL ) {
1420|    m_wndView->SetScrollSize();
1421|    m_wndView->Invalidate( FALSE );
1422|    SetDefaultMode();
1423|    ResetProp();
1424|  }
1425|}
1426|
1427|
1428| 
1429|/***********************************************************************
1430|  13-3. <<< [CMainFrame::OnNewWindow] 新しい SVG Cats を開く >>> 
1431|************************************************************************/
1432|void CMainFrame::OnNewWindow()
1433|{
1434|  WinExec( StrX_argv0, SW_SHOWNORMAL );
1435|}
1436| 
1437|/***********************************************************************
1438|  13-4. <<< [CMainFrame::OnOpen] (ファイルを)開くを選んだときの処理 >>> 
1439|************************************************************************/
1440|void CMainFrame::OnOpen()
1441|{
1442|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
1443|
1444|  OnOpen_sub( m_FolderPathOnOpen, true, false );
1445|  StrX_cpyFolder( m_FolderPathOnOpen, app->m_path );
1446|}
1447|
1448|
1449|void CMainFrame::OnOpen_sub( const char* folderPathOnOpen, bool bUpdateRecent,
1450|  bool bUseTemplate )
1451|{
1452|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
1453|  CFileDialog  dlg( TRUE, "svg", NULL, OFN_HIDEREADONLY,
1454|                    app->m_bJapanese ? _svg_read_filter : _svg_read_filterE );
1455|  CString  s;
1456|
1457|  m_wndView->OnFinishPrimMove();
1458|  m_wndView->ResetSelect();
1459|
1460|  #ifdef  NDEBUG
1461|    dlg.m_ofn.Flags &= ~OFN_ENABLEHOOK;  /* Win2000以降の新しいファイルダイアログにする */
1462|  #endif
1463|  dlg.m_ofn.lpstrInitialDir = folderPathOnOpen;
1464|
1465|
1466|  /* 編集していたら、保存する */
1467|  if ( m_wndView->IsDirty() ) {
1468|    int  r;
1469|
1470|    if ( app->m_bJapanese )  s.LoadString( IDS_SaveConfirm );
1471|    else  s.LoadString( IDS_SaveConfirm_E );
1472|
1473|    ::SetWindowPos( m_hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE );
1474|    r = MessageBox( s, app->m_path, MB_YESNOCANCEL | MB_ICONWARNING );
1475|    switch ( r ) {
1476|     case  IDYES:  OnSaveOv();  break;
1477|     case  IDCANCEL:  return;
1478|    }
1479|  }
1480|
1481|  /* SVG ファイルを開く */
1482|  if ( dlg.DoModal() == IDOK ) {
1483|    if ( app->m_bTaskTray && stricmp( dlg.GetPathName(), app->m_path ) != 0 ) {
1484|      char  command[_MAX_PATH*2];
1485|
1486|      strcpy( command, StrX_argv0 );
1487|      if ( bUseTemplate )  strcat( command, " -p" );
1488|      strcat( command, " \"" );
1489|      strcat( command, dlg.GetPathName() );
1490|      strcat( command, "\"" );
1491|
1492|      WinExec( command, SW_SHOW );
1493|    }
1494|    else {
1495|      RestoreWindow( true, NULL );
1496|      Load( dlg.GetPathName(), bUpdateRecent );
1497|    }
1498|  }
1499|}
1500|
1501|
1502| 
1503|/***********************************************************************
1504|  13-5. <<< [CMainFrame::OnOpenTemplate] テンプレートを使って開くを選んだときの処理 >>> 
1505|************************************************************************/
1506|void CMainFrame::OnOpenTemplate()
1507|{
1508|  char  path[_MAX_PATH];
1509|
1510|  StrX_getExeFullPath( path, _template_path, sizeof(path) );
1511|  OnOpen_sub( path, false, true );
1512|
1513|
1514|#if 0
1515|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
1516|  char  path[_MAX_PATH];
1517|
1518|  StrX_getExeFullPath( path, _template_path, sizeof(path) );
1519|  OnOpen_sub( path, false );
1520|
1521|  app->m_path[0] = '\0';
1522|
1523|  strcpy( path, app->m_backPath );
1524|  app->ChangeBackup();
1525|  MoveFile( path, app->m_backPath );
1526|
1527|  UpdateWindowText();
1528|#endif
1529|}
1530|
1531|
1532| 
1533|/***********************************************************************
1534|  13-6. <<< [CMainFrame::OnDropFiles] エクスプローラからファイルをドラッグされたときの処理 >>> 
1535|************************************************************************/
1536|#include <intshcut.h>
1537|
1538|void  CMainFrame::OnDropFiles( HDROP hDropInfo )
1539|{
1540|  DropFiles( hDropInfo );
1541|  DragFinish( hDropInfo );
1542|}
1543|
1544|void  CMainFrame::DropFiles( HDROP hDropInfo )
1545|{
1546|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
1547|  char*  ext;
1548|  char  path[_MAX_PATH];
1549|  char  fname[_MAX_PATH];
1550|  CString  s;
1551|  bool  bShortCut = false;
1552|  CPoint  point, pt;
1553|
1554|  m_wndView->OnFinishPrimMove();
1555|  m_wndView->ResetSelect();
1556|
1557|  GetCursorPos( &point );
1558|  m_wndView->ScreenToClient( &point );
1559|  pt = m_wndView->GetScrollPosition();
1560|  point += pt;
1561|  point -= m_wndView->m_MinusOffset;
1562|  point.x = point.x * 100 / m_wndView->m_Zoom;
1563|  point.y = point.y * 100 / m_wndView->m_Zoom;
1564|
1565|  DragQueryFile( hDropInfo, 0, path, sizeof(path) );
1566|  ext = StrX_refExt( path );
1567|
1568|  StrX_cpyFName( fname, path );  StrX_chgExt( fname, "" );
1569|  ::SetWindowPos( m_hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE );
1570|
1571|
1572|  /* SVG ファイルを開く */
1573|  if ( stricmp( ext, "svg" ) == 0 || stricmp( ext, "svgz" ) == 0 ) {
1574|    SetForegroundWindow();
1575|    if ( MessageBox( app->m_bJapanese ? "この SVG ファイルを開きますか?\r\n"
1576|      "SVG ファイルを開く=[はい]\r\nショートカットを作成する=[いいえ]" :
1577|      "Are you want to open SVG file?\r\n"
1578|      "Open=[Yes], Create Shortcut=[No]", fname, MB_YESNO )
1579|      == IDNO ) {
1580|      bShortCut = true;
1581|    }
1582|  }
1583|
1584|  if ( !bShortCut && stricmp( ext, "svg" ) == 0 || stricmp( ext, "svgz" ) == 0 ) {
1585|
1586|    /* 編集していたら、保存する */
1587|    if ( m_wndView->IsDirty() ) {
1588|      int  r;
1589|
1590|      if ( app->m_bJapanese )  s.LoadString( IDS_SaveConfirm );
1591|      else  s.LoadString( IDS_SaveConfirm_E );
1592|
1593|      ::SetWindowPos( m_hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE );
1594|      r = MessageBox( s, app->m_path, MB_YESNOCANCEL | MB_ICONWARNING );
1595|      switch ( r ) {
1596|       case  IDYES:  OnSaveOv();  break;
1597|       case  IDCANCEL:  DragFinish( hDropInfo );  return;
1598|      }
1599|    }
1600|
1601|    Load( path, true );
1602|  }
1603|
1604|  /* 画像を追加する */
1605|  else if ( !bShortCut && ( stricmp( ext, "jpg" ) == 0 || stricmp( ext, "jpeg" ) == 0 ||
1606|            stricmp( ext, "gif" ) == 0 || stricmp( ext, "png" ) == 0 ) ) {
1607|    Rect_Ex*  rect;
1608|    ListX_ElemX*  p;
1609|
1610|    OnSelect();
1611|
1612|    for ( ListX_forEach( &m_wndView->m_MultiHolds, &p, ListX_ElemX ) )
1613|      ((CadPrim*)p->p)->SetHold( false );
1614|    ListX_toEmptyDelete( &m_wndView->m_MultiHolds, ListX_ElemX, NULL );
1615|    for ( ListX_forEach( &m_wndView->m_MultiBefore, &p, ListX_ElemX) )
1616|      delete  (CadPrim*)p->p;
1617|    ListX_toEmptyDelete( &m_wndView->m_MultiBefore, ListX_ElemX, NULL );
1618|
1619|    rect = new Rect_Ex;
1620|    rect->m_id = app->GetNewPrimID();
1621|    rect->m_bSelected = true;
1622|    Rect_init( &rect->m_Rect, point.x, point.y, 1, 1 );
1623|    rect->m_BorderWidth = 1;
1624|    rect->m_BorderColor = 0;
1625|    rect->m_FillColor = 0xFFFFFF;
1626|    rect->m_ShapeType = Rect_ImageShape;
1627|    rect->m_ImgPath = path;
1628|    rect->m_ImgWorkPath = app->GetImgWorkFilePath( (long)m_hWnd );
1629|    rect->m_Target = "_blank";
1630|    app->AddPrim( &app->m_file, rect );
1631|
1632|    m_wndView->m_HoldPrim = rect;
1633|    ListX_toEmptyDelete( &m_wndView->m_MultiHolds, ListX_ElemX, NULL );
1634|    p = ListX_addLastMalloc( &m_wndView->m_MultiHolds, ListX_ElemX );
1635|    p->p = m_wndView->m_HoldPrim;
1636|    rect->SetHold( true );
1637|    app->m_UndoBuf->AllocNewStep( NULL, rect->GetNewCopy( &app->m_file.m_prims ), NULL, NULL,
1638|      app->m_file.m_CurrentPageNum - app->m_file.m_StartPageNum );
1639|    m_wndView->SetMultiSelect();
1640|    m_wndView->Redraw( false );
1641|    SetPropMulti( &m_wndView->m_MultiHolds, m_wndView->m_HoldStrokes );
1642|  }
1643|
1644|  /* リンクを追加する */
1645|  else {
1646|    Text_Box*  text;
1647|    CadPrim_DrawParam  pa;
1648|    ListX_ElemX*  p;
1649|    WCHAR  path_w[MAX_PATH];
1650|    char*  path2 = path;
1651|    char   path2X[_MAX_PATH];
1652|    HRESULT  hr;
1653|
1654|    m_wndView->ResetSelect();
1655|
1656|    /* リンク先を取得する */
1657|    if ( stricmp( ext, "lnk" ) == 0 ) {
1658|      IShellLink*  link;
1659|      IPersistFile*  pfile;
1660|
1661|      hr = CoCreateInstance( CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
1662|        IID_IShellLink, (void**)&link );
1663|      if ( hr != 0 )  error();
1664|
1665|      StrX_sjis2unicode( path_w, path, sizeof(path_w) );
1666|
1667|      hr = link->QueryInterface( IID_IPersistFile, (void**)&pfile );
1668|      if ( hr != 0 )  error();
1669|
1670|      hr = pfile->Load( path_w, STGM_READ );
1671|      if ( hr != 0 )  error();
1672|
1673|            link->GetPath( path2X, MAX_PATH, NULL, SLGP_UNCPRIORITY );
1674|      path2 = path2X;
1675|
1676|        pfile->Release();
1677|            link->Release();
1678|    }
1679|
1680|    else if ( stricmp( ext, "url" ) == 0 ) {
1681|      IUniformResourceLocator* link;
1682|      LPSTR  path2p;
1683|      IMalloc*  mem;
1684|      IPersistFile*  pfile;
1685|
1686|      hr = CoCreateInstance( CLSID_InternetShortcut, NULL, CLSCTX_INPROC_SERVER,
1687|        IID_IUniformResourceLocator, (void**)&link );
1688|      if ( hr != 0 )  error();
1689|
1690|      StrX_sjis2unicode( path_w, path, sizeof(path_w) );
1691|
1692|      hr = link->QueryInterface( IID_IPersistFile, (void**)&pfile );
1693|      if ( hr != 0 )  error();
1694|
1695|      hr = pfile->Load( path_w, STGM_READ );
1696|      if ( hr != 0 )  error();
1697|
1698|      hr = link->GetURL( &path2p );
1699|      if ( hr != 0 )  error();
1700|
1701|      strcpy( path2X, path2p );
1702|      path2 = path2X;
1703|
1704|      hr = SHGetMalloc( &mem );
1705|      mem->Free( path2p );
1706|      mem->Release();
1707|
1708|        pfile->Release();
1709|            link->Release();
1710|    }
1711|
1712|    /* 枠付きテキストを作成する */
1713|    if ( m_TextRectDesign != NULL ) {
1714|      text = (Text_Box*)m_TextRectDesign->GetNewCopy( &app->m_file.m_prims );
1715|    }
1716|    else {
1717|      text = new Text_Box;
1718|      text->m_W = 100;  text->m_10H = 320;
1719|      text->m_Color = 0;
1720|      text->m_Font = ( app->m_bJapanese ? "MS Pゴシック" : "Arial" );
1721|      text->m_Size = 10;
1722|      text->m_bBold = false;  text->m_bItalic = false;
1723|      text->m_BasePos = Text_Box_LeftAlign;
1724|      text->m_BoxShape = Text_Box_RectShape;
1725|      text->m_BoxMarginX = 8;  text->m_BoxMarginY = 6;
1726|      text->m_BorderWidth = 1;
1727|      text->m_BorderColor = 0x000000;
1728|      text->m_FillColor = 0xFFFFFF;
1729|    }
1730|
1731|    text->m_id = app->GetNewPrimID();
1732|    text->m_Text = fname;
1733|    text->m_URL = path2;
1734|    text->m_Target = "_blank";
1735|    text->m_bHold = true;
1736|    m_wndView->GetDrawParam( &pa );
1737|    text->Draw( &m_wndView->m_MinBitmapDC, &pa );  /* マージンを設定する */
1738|    text->m_CenterX = point.x;  text->m_Y = point.y;
1739|
1740|    text->SetHold( true );
1741|    app->AddPrim( &app->m_file, text );
1742|    m_wndView->m_HoldPrim = text;
1743|    p = ListX_addFirstMalloc( &m_wndView->m_MultiHolds, ListX_ElemX );
1744|    p->p = text;
1745|    m_wndView->SetMultiSelect();
1746|
1747|    app->m_UndoBuf->AllocNewStep( NULL,
1748|      text->GetNewCopy( &app->m_file.m_prims ), NULL, NULL, app->m_file.m_CurrentPageNum - app->m_file.m_StartPageNum );
1749|
1750|    m_wndView->Redraw( false );
1751|    SetPropMulti( &m_wndView->m_MultiHolds, m_wndView->m_HoldStrokes );
1752|  }
1753|}
1754|
1755|
1756| 
1757|/***********************************************************************
1758|  13-7. <<< [CMainFrame::OnCapture] 画面を切り取る(スクリーンキャプチャー) >>> 
1759|************************************************************************/
1760|extern "C" { void  CompressPictureToJpeg( int w, int h, int w_stride, char* bmp, int bReverse, int bpp, const char* out_path ); }
1761|LRESULT CALLBACK  CMainFrame_CaptureProc( HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam );
1762|void  CMainFrame_DrawCaptureLine( HDC dc, int x, int y, int dirX1Y2, int xy2 );
1763|
1764|/* キャプチャ範囲選択開始 */
1765|void CMainFrame::OnCapture()
1766|{
1767|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
1768|  CMainFrame*  frame = (CMainFrame*)app->m_pMainWnd;
1769|  CChildView*  view = frame->m_wndView;
1770|  int  waitSec;
1771|  bool  bWhole;
1772|  CCaptureDlg  dlg;
1773|
1774|  dlg.m_bPNG = ( app->m_DefaultImageType == 1 );
1775|
1776|  if ( dlg.DoModal() == IDCANCEL ) {
1777|    return;
1778|  }
1779|  waitSec = dlg.m_SecNum;
1780|  bWhole = dlg.m_bWhole != 0;
1781|  m_bCaptureFormat = dlg.m_bPNG;
1782|
1783|  app->m_DefaultImageType = ( dlg.m_bPNG ? 1 : 2 );
1784|  app->SaveSVGCatsIni();
1785|
1786|  m_bVisibleBeforeCapture = ( IsWindowVisible() != 0 );
1787|
1788|  HideWindow();
1789|  Sleep(400);  /* 非表示にしてから他のウィンドウを描画するために待つ */
1790|
1791|  Sleep( waitSec * 1000 );
1792|
1793|
1794|  /* 画面全体を切り取る */
1795|  if ( bWhole ) {
1796|    HWND desktop = ::GetDesktopWindow();
1797|    HDC  desktopDC;
1798|
1799|    desktopDC = ::GetDC( desktop );
1800|    view->m_DownS.x = 0;
1801|    view->m_DownS.y = 0;
1802|    view->m_UpS.x = GetDeviceCaps( desktopDC, HORZRES ) - 1;
1803|    view->m_UpS.y = GetDeviceCaps( desktopDC, VERTRES ) - 1;
1804|    ::ReleaseDC( desktop, desktopDC );
1805|
1806|    OnCapture2();
1807|  }
1808|
1809|  /* 画面の一部を切り取る */
1810|  else {
1811|
1812|    /* WM_PAINT しないポップアップウインドウを使って、キャプチャーする範囲を選択する */
1813|    {
1814|	    WNDCLASSEX	wc;
1815|
1816|	    memset( &wc , 0, sizeof(WNDCLASSEX) );
1817|	    wc.cbSize = sizeof(WNDCLASSEX);
1818|	    wc.lpfnWndProc = CMainFrame_CaptureProc;
1819|	    wc.hInstance = app->m_hInstance;
1820|	    wc.hCursor = LoadCursor( NULL, IDC_CROSS );
1821|	    wc.hbrBackground = (HBRUSH)GetStockObject( NULL_BRUSH );
1822|	    wc.lpszClassName = "CaptureArea";
1823|
1824|	    RegisterClassEx( &wc );
1825|
1826|	    m_CaptureArea = CreateWindow( "CaptureArea", "CaptureArea",
1827|			    WS_POPUP | WS_VISIBLE, 0, 0,
1828|          GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN),
1829|			    m_hWnd, NULL,	app->m_hInstance, NULL );
1830|
1831|      ::SetWindowPos( m_CaptureArea, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE );
1832|    }
1833|
1834|    view->m_DownS.x = -1;  view->m_DownS.y = 0;
1835|    frame->m_CaptureStep = 1;
1836|  }
1837|}
1838|
1839|
1840|/* キャプチャ範囲選択中 */
1841|LRESULT CALLBACK  CMainFrame_CaptureProc( HWND wnd, UINT msg, WPARAM wParam, LPARAM lParam )
1842|{
1843|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
1844|  CMainFrame*  frame = (CMainFrame*)app->m_pMainWnd;
1845|  CChildView*  view = frame->m_wndView;
1846|  RECT  rc;
1847|  HWND  targetWnd;
1848|  HWND  targetWnd2;
1849|
1850|  switch ( msg ) {
1851|    case WM_LBUTTONUP:
1852|      if ( frame->m_CaptureStep != 2 ||
1853|           ( abs( view->m_UpS.x - view->m_DownS.x ) < 8 &&
1854|             abs( view->m_UpS.y - view->m_DownS.y ) < 8 ) ) {
1855|        break;
1856|      }
1857|      /* continue to next case */
1858|
1859|    case WM_LBUTTONDOWN:
1860|      if ( frame->m_CaptureStep == 1 ) {
1861|        HWND desktop = ::GetDesktopWindow();
1862|        HDC  desktopDC;
1863|        HDC  popupDC;
1864|        int  x, y, w, h;
1865|
1866|        desktopDC = GetDC( desktop );
1867|        popupDC = GetDC( wnd );
1868|        w = GetDeviceCaps( desktopDC, HORZRES );
1869|        h = GetDeviceCaps( desktopDC, VERTRES );
1870|
1871|
1872|        /* 前に書いたガイドラインを消す */
1873|        x = view->m_DownS.x;  y = view->m_DownS.y;
1874|        CMainFrame_DrawCaptureLine( popupDC, x-1, y-1, 1, w-1 );
1875|        CMainFrame_DrawCaptureLine( popupDC, x-1, y-2, 1, w-1 );
1876|        CMainFrame_DrawCaptureLine( popupDC, x-1, y-1, 2, h-1 );
1877|        CMainFrame_DrawCaptureLine( popupDC, x-2, y-1, 2, h-1 );
1878|
1879|        for ( targetWnd = ::GetTopWindow( ::GetDesktopWindow() );
1880|              targetWnd != NULL;
1881|              targetWnd = ::GetNextWindow( targetWnd, GW_HWNDNEXT ) ) {
1882|          if ( targetWnd == wnd )  continue;
1883|          if ( ! ::IsWindowVisible( targetWnd ) )  continue;
1884|          ::GetWindowRect( targetWnd, &rc );
1885|          if ( rc.left <= x && x <= rc.right && rc.top <= y && y <= rc.bottom ) {
1886|            for ( targetWnd2 = ::GetTopWindow( targetWnd );
1887|                  targetWnd2 != NULL;
1888|                  targetWnd2 = ::GetNextWindow( targetWnd2, GW_HWNDNEXT ) ) {
1889|              if ( ! ::IsWindowVisible( targetWnd2 ) )  continue;
1890|              ::GetWindowRect( targetWnd2, &rc );
1891|              if ( rc.left <= x && x <= rc.right && rc.top <= y && y <= rc.bottom ) {
1892|                break;
1893|              }
1894|            }
1895|            if ( targetWnd2 == NULL )  ::GetWindowRect( targetWnd, &rc );
1896|            break;
1897|          }
1898|        }
1899|        if ( targetWnd == NULL )  ::GetWindowRect( desktop, &rc );
1900|        CMainFrame_DrawCaptureLine( popupDC, rc.left, rc.top-1, 1, rc.right );
1901|        CMainFrame_DrawCaptureLine( popupDC, rc.left, rc.top-2, 1, rc.right );
1902|        CMainFrame_DrawCaptureLine( popupDC, rc.right+0, rc.top, 2, rc.bottom );
1903|        CMainFrame_DrawCaptureLine( popupDC, rc.right+1, rc.top, 2, rc.bottom );
1904|        CMainFrame_DrawCaptureLine( popupDC, rc.left, rc.bottom+0, 1, rc.right );
1905|        CMainFrame_DrawCaptureLine( popupDC, rc.left, rc.bottom+1, 1, rc.right );
1906|        CMainFrame_DrawCaptureLine( popupDC, rc.left-1, rc.top, 2, rc.bottom );
1907|        CMainFrame_DrawCaptureLine( popupDC, rc.left-2, rc.top, 2, rc.bottom );
1908|
1909|
1910|        /* ガイドライン(ウィンドウ枠のみ)を描画する */
1911|        view->m_UpS = view->m_DownS;
1912|
1913|        for ( targetWnd = ::GetTopWindow( ::GetDesktopWindow() );
1914|              targetWnd != NULL;
1915|              targetWnd = ::GetNextWindow( targetWnd, GW_HWNDNEXT ) ) {
1916|          if ( targetWnd == wnd )  continue;
1917|          if ( ! ::IsWindowVisible( targetWnd ) )  continue;
1918|          ::GetWindowRect( targetWnd, &rc );
1919|          if ( rc.left <= x && x <= rc.right && rc.top <= y && y <= rc.bottom ) {
1920|            for ( targetWnd2 = ::GetTopWindow( targetWnd );
1921|                  targetWnd2 != NULL;
1922|                  targetWnd2 = ::GetNextWindow( targetWnd2, GW_HWNDNEXT ) ) {
1923|              if ( ! ::IsWindowVisible( targetWnd2 ) )  continue;
1924|              ::GetWindowRect( targetWnd2, &rc );
1925|              if ( rc.left <= x && x <= rc.right && rc.top <= y && y <= rc.bottom ) {
1926|                break;
1927|              }
1928|            }
1929|            if ( targetWnd2 == NULL )  ::GetWindowRect( targetWnd, &rc );
1930|            break;
1931|          }
1932|        }
1933|        if ( targetWnd == NULL )  ::GetWindowRect( desktop, &rc );
1934|        CMainFrame_DrawCaptureLine( popupDC, rc.left, rc.top-1, 1, rc.right );
1935|        CMainFrame_DrawCaptureLine( popupDC, rc.left, rc.top-2, 1, rc.right );
1936|        CMainFrame_DrawCaptureLine( popupDC, rc.right+0, rc.top, 2, rc.bottom );
1937|        CMainFrame_DrawCaptureLine( popupDC, rc.right+1, rc.top, 2, rc.bottom );
1938|        CMainFrame_DrawCaptureLine( popupDC, rc.left, rc.bottom+0, 1, rc.right );
1939|        CMainFrame_DrawCaptureLine( popupDC, rc.left, rc.bottom+1, 1, rc.right );
1940|        CMainFrame_DrawCaptureLine( popupDC, rc.left-1, rc.top, 2, rc.bottom );
1941|        CMainFrame_DrawCaptureLine( popupDC, rc.left-2, rc.top, 2, rc.bottom );
1942|
1943|        ReleaseDC( wnd, popupDC );
1944|        ReleaseDC( desktop, desktopDC );
1945|
1946|        frame->m_CaptureStep ++;
1947|      }
1948|      else {
1949|        frame->PostMessage( WM_COMMAND, CMainFrame_Capture2, NULL );
1950|      }
1951|      break;
1952|
1953|    case WM_RBUTTONUP:
1954|      view->m_UpS = view->m_DownS;
1955|      view->m_UpS.x --;
1956|      frame->PostMessage( WM_COMMAND, CMainFrame_Capture2, NULL );
1957|      break;
1958|
1959|    case WM_MOUSEMOVE: {
1960|      HWND desktop = ::GetDesktopWindow();
1961|      HDC  desktopDC;
1962|      HDC  popupDC;
1963|      int  x, y, w, h;
1964|
1965|      desktopDC = GetDC( desktop );
1966|      popupDC = GetDC( wnd );
1967|      w = GetDeviceCaps( desktopDC, HORZRES );
1968|      h = GetDeviceCaps( desktopDC, VERTRES );
1969|
1970|      if ( frame->m_CaptureStep == 1 ) {
1971|
1972|        /* 前に書いたガイドラインを消す */
1973|        if ( view->m_DownS.x != -1 ) {
1974|          x = view->m_DownS.x;  y = view->m_DownS.y;
1975|          CMainFrame_DrawCaptureLine( popupDC, x-1, y-1, 1, w-1 );
1976|          CMainFrame_DrawCaptureLine( popupDC, x-1, y-2, 1, w-1 );
1977|          CMainFrame_DrawCaptureLine( popupDC, x-1, y-1, 2, h-1 );
1978|          CMainFrame_DrawCaptureLine( popupDC, x-2, y-1, 2, h-1 );
1979|
1980|          for ( targetWnd = ::GetTopWindow( ::GetDesktopWindow() );
1981|                targetWnd != NULL;
1982|                targetWnd = ::GetNextWindow( targetWnd, GW_HWNDNEXT ) ) {
1983|            if ( targetWnd == wnd )  continue;
1984|            if ( ! ::IsWindowVisible( targetWnd ) )  continue;
1985|            ::GetWindowRect( targetWnd, &rc );
1986|            if ( rc.left <= x && x <= rc.right && rc.top <= y && y <= rc.bottom ) {
1987|              for ( targetWnd2 = ::GetTopWindow( targetWnd );
1988|                    targetWnd2 != NULL;
1989|                    targetWnd2 = ::GetNextWindow( targetWnd2, GW_HWNDNEXT ) ) {
1990|                if ( ! ::IsWindowVisible( targetWnd2 ) )  continue;
1991|                ::GetWindowRect( targetWnd2, &rc );
1992|                if ( rc.left <= x && x <= rc.right && rc.top <= y && y <= rc.bottom ) {
1993|                  break;
1994|                }
1995|              }
1996|              if ( targetWnd2 == NULL )  ::GetWindowRect( targetWnd, &rc );
1997|              break;
1998|            }
1999|          }
2000|          if ( targetWnd == NULL )  ::GetWindowRect( desktop, &rc );
2001|          CMainFrame_DrawCaptureLine( popupDC, rc.left, rc.top-1, 1, rc.right );
2002|          CMainFrame_DrawCaptureLine( popupDC, rc.left, rc.top-2, 1, rc.right );
2003|          CMainFrame_DrawCaptureLine( popupDC, rc.right+0, rc.top, 2, rc.bottom );
2004|          CMainFrame_DrawCaptureLine( popupDC, rc.right+1, rc.top, 2, rc.bottom );
2005|          CMainFrame_DrawCaptureLine( popupDC, rc.left, rc.bottom+0, 1, rc.right );
2006|          CMainFrame_DrawCaptureLine( popupDC, rc.left, rc.bottom+1, 1, rc.right );
2007|          CMainFrame_DrawCaptureLine( popupDC, rc.left-1, rc.top, 2, rc.bottom );
2008|          CMainFrame_DrawCaptureLine( popupDC, rc.left-2, rc.top, 2, rc.bottom );
2009|        }
2010|
2011|        /* ガイドラインを描画する */
2012|        x = LOWORD(lParam);  y = HIWORD(lParam);
2013|        CMainFrame_DrawCaptureLine( popupDC, x-1, y-1, 1, w-1 );
2014|        CMainFrame_DrawCaptureLine( popupDC, x-1, y-2, 1, w-1 );
2015|        CMainFrame_DrawCaptureLine( popupDC, x-1, y-1, 2, h-1 );
2016|        CMainFrame_DrawCaptureLine( popupDC, x-2, y-1, 2, h-1 );
2017|
2018|        for ( targetWnd = ::GetTopWindow( ::GetDesktopWindow() );
2019|              targetWnd != NULL;
2020|              targetWnd = ::GetNextWindow( targetWnd, GW_HWNDNEXT ) ) {
2021|          if ( targetWnd == wnd )  continue;
2022|          if ( ! ::IsWindowVisible( targetWnd ) )  continue;
2023|          ::GetWindowRect( targetWnd, &rc );
2024|          if ( rc.left <= x && x <= rc.right && rc.top <= y && y <= rc.bottom ) {
2025|            for ( targetWnd2 = ::GetTopWindow( targetWnd );
2026|                  targetWnd2 != NULL;
2027|                  targetWnd2 = ::GetNextWindow( targetWnd2, GW_HWNDNEXT ) ) {
2028|              if ( ! ::IsWindowVisible( targetWnd2 ) )  continue;
2029|              ::GetWindowRect( targetWnd2, &rc );
2030|              if ( rc.left <= x && x <= rc.right && rc.top <= y && y <= rc.bottom ) {
2031|                break;
2032|              }
2033|            }
2034|            if ( targetWnd2 == NULL )  ::GetWindowRect( targetWnd, &rc );
2035|            break;
2036|          }
2037|        }
2038|        if ( targetWnd == NULL )  ::GetWindowRect( desktop, &rc );
2039|        CMainFrame_DrawCaptureLine( popupDC, rc.left, rc.top-1, 1, rc.right );
2040|        CMainFrame_DrawCaptureLine( popupDC, rc.left, rc.top-2, 1, rc.right );
2041|        CMainFrame_DrawCaptureLine( popupDC, rc.right+0, rc.top, 2, rc.bottom );
2042|        CMainFrame_DrawCaptureLine( popupDC, rc.right+1, rc.top, 2, rc.bottom );
2043|        CMainFrame_DrawCaptureLine( popupDC, rc.left, rc.bottom+0, 1, rc.right );
2044|        CMainFrame_DrawCaptureLine( popupDC, rc.left, rc.bottom+1, 1, rc.right );
2045|        CMainFrame_DrawCaptureLine( popupDC, rc.left-1, rc.top, 2, rc.bottom );
2046|        CMainFrame_DrawCaptureLine( popupDC, rc.left-2, rc.top, 2, rc.bottom );
2047|
2048|        view->m_DownS.x = x;  view->m_DownS.y = y;
2049|      }
2050|
2051|      else {
2052|
2053|        /* 前に書いたガイドラインを消す */
2054|        x = view->m_UpS.x;  y = view->m_UpS.y;
2055|
2056|        if ( x - view->m_DownS.x >= 8 ) {
2057|          CMainFrame_DrawCaptureLine( popupDC, view->m_DownS.x-1, y+1, 1, x+1 );
2058|          CMainFrame_DrawCaptureLine( popupDC, view->m_DownS.x-1, y+2, 1, x+1 );
2059|          CMainFrame_DrawCaptureLine( popupDC, x+1, view->m_DownS.y-1, 2, y+1 );
2060|          CMainFrame_DrawCaptureLine( popupDC, x+2, view->m_DownS.y-1, 2, y+1 );
2061|
2062|          CMainFrame_DrawCaptureLine( popupDC, view->m_DownS.x-1, view->m_DownS.y-1, 1, x+1 );
2063|          CMainFrame_DrawCaptureLine( popupDC, view->m_DownS.x-1, view->m_DownS.y-2, 1, x+1 );
2064|          CMainFrame_DrawCaptureLine( popupDC, view->m_DownS.x-1, view->m_DownS.y-1, 2, y+1 );
2065|          CMainFrame_DrawCaptureLine( popupDC, view->m_DownS.x-2, view->m_DownS.y-1, 2, y+1 );
2066|        }
2067|        else {
2068|          for ( targetWnd = ::GetTopWindow( ::GetDesktopWindow() );
2069|                targetWnd != NULL;
2070|                targetWnd = ::GetNextWindow( targetWnd, GW_HWNDNEXT ) ) {
2071|            if ( targetWnd == wnd )  continue;
2072|            if ( ! ::IsWindowVisible( targetWnd ) )  continue;
2073|            ::GetWindowRect( targetWnd, &rc );
2074|            if ( rc.left <= x && x <= rc.right && rc.top <= y && y <= rc.bottom ) {
2075|              for ( targetWnd2 = ::GetTopWindow( targetWnd );
2076|                    targetWnd2 != NULL;
2077|                    targetWnd2 = ::GetNextWindow( targetWnd2, GW_HWNDNEXT ) ) {
2078|                if ( ! ::IsWindowVisible( targetWnd2 ) )  continue;
2079|                ::GetWindowRect( targetWnd2, &rc );
2080|                if ( rc.left <= x && x <= rc.right && rc.top <= y && y <= rc.bottom ) {
2081|                  break;
2082|                }
2083|              }
2084|              if ( targetWnd2 == NULL )  ::GetWindowRect( targetWnd, &rc );
2085|              break;
2086|            }
2087|          }
2088|          if ( targetWnd == NULL )  ::GetWindowRect( desktop, &rc );
2089|          CMainFrame_DrawCaptureLine( popupDC, rc.left, rc.top-1, 1, rc.right );
2090|          CMainFrame_DrawCaptureLine( popupDC, rc.left, rc.top-2, 1, rc.right );
2091|          CMainFrame_DrawCaptureLine( popupDC, rc.right+0, rc.top, 2, rc.bottom );
2092|          CMainFrame_DrawCaptureLine( popupDC, rc.right+1, rc.top, 2, rc.bottom );
2093|          CMainFrame_DrawCaptureLine( popupDC, rc.left, rc.bottom+0, 1, rc.right );
2094|          CMainFrame_DrawCaptureLine( popupDC, rc.left, rc.bottom+1, 1, rc.right );
2095|          CMainFrame_DrawCaptureLine( popupDC, rc.left-1, rc.top, 2, rc.bottom );
2096|          CMainFrame_DrawCaptureLine( popupDC, rc.left-2, rc.top, 2, rc.bottom );
2097|        }
2098|
2099|
2100|        /* ガイドラインを描画する */
2101|        x = LOWORD(lParam);  y = HIWORD(lParam);
2102|
2103|        if ( x - view->m_DownS.x >= 8 ) {
2104|          CMainFrame_DrawCaptureLine( popupDC, view->m_DownS.x-1, y+1, 1, x+1 );
2105|          CMainFrame_DrawCaptureLine( popupDC, view->m_DownS.x-1, y+2, 1, x+1 );
2106|          CMainFrame_DrawCaptureLine( popupDC, x+1, view->m_DownS.y-1, 2, y+1 );
2107|          CMainFrame_DrawCaptureLine( popupDC, x+2, view->m_DownS.y-1, 2, y+1 );
2108|
2109|          CMainFrame_DrawCaptureLine( popupDC, view->m_DownS.x-1, view->m_DownS.y-1, 1, x+1 );
2110|          CMainFrame_DrawCaptureLine( popupDC, view->m_DownS.x-1, view->m_DownS.y-2, 1, x+1 );
2111|          CMainFrame_DrawCaptureLine( popupDC, view->m_DownS.x-1, view->m_DownS.y-1, 2, y+1 );
2112|          CMainFrame_DrawCaptureLine( popupDC, view->m_DownS.x-2, view->m_DownS.y-1, 2, y+1 );
2113|        }
2114|        else {
2115|          for ( targetWnd = ::GetTopWindow( ::GetDesktopWindow() );
2116|                targetWnd != NULL;
2117|                targetWnd = ::GetNextWindow( targetWnd, GW_HWNDNEXT ) ) {
2118|            if ( targetWnd == wnd )  continue;
2119|            if ( ! ::IsWindowVisible( targetWnd ) )  continue;
2120|            ::GetWindowRect( targetWnd, &rc );
2121|            if ( rc.left <= x && x <= rc.right && rc.top <= y && y <= rc.bottom ) {
2122|              for ( targetWnd2 = ::GetTopWindow( targetWnd );
2123|                    targetWnd2 != NULL;
2124|                    targetWnd2 = ::GetNextWindow( targetWnd2, GW_HWNDNEXT ) ) {
2125|                if ( ! ::IsWindowVisible( targetWnd2 ) )  continue;
2126|                ::GetWindowRect( targetWnd2, &rc );
2127|                if ( rc.left <= x && x <= rc.right && rc.top <= y && y <= rc.bottom ) {
2128|                  break;
2129|                }
2130|              }
2131|              if ( targetWnd2 == NULL )  ::GetWindowRect( targetWnd, &rc );
2132|              break;
2133|            }
2134|          }
2135|          if ( targetWnd == NULL )  ::GetWindowRect( desktop, &rc );
2136|          CMainFrame_DrawCaptureLine( popupDC, rc.left, rc.top-1, 1, rc.right );
2137|          CMainFrame_DrawCaptureLine( popupDC, rc.left, rc.top-2, 1, rc.right );
2138|          CMainFrame_DrawCaptureLine( popupDC, rc.right+0, rc.top, 2, rc.bottom );
2139|          CMainFrame_DrawCaptureLine( popupDC, rc.right+1, rc.top, 2, rc.bottom );
2140|          CMainFrame_DrawCaptureLine( popupDC, rc.left, rc.bottom+0, 1, rc.right );
2141|          CMainFrame_DrawCaptureLine( popupDC, rc.left, rc.bottom+1, 1, rc.right );
2142|          CMainFrame_DrawCaptureLine( popupDC, rc.left-1, rc.top, 2, rc.bottom );
2143|          CMainFrame_DrawCaptureLine( popupDC, rc.left-2, rc.top, 2, rc.bottom );
2144|        }
2145|        view->m_UpS.x = x;  view->m_UpS.y = y;
2146|      }
2147|
2148|      ReleaseDC( wnd, popupDC );
2149|      ReleaseDC( desktop, desktopDC );
2150|      break;
2151|    }
2152|
2153|    default:
2154|      return DefWindowProc( wnd, msg, wParam, lParam );
2155|  }
2156|  return  0;
2157|}
2158|
2159|
2160|void  CMainFrame_DrawCaptureLine( HDC dc, int x, int y, int dirX1Y2, int xy2 )
2161|{
2162|  switch ( dirX1Y2 ) {
2163|
2164|    case 1:  /* 水平線 */
2165|      for ( ; x < xy2; x++ ) {
2166|        if ( x & 8 )
2167|          SetPixel( dc, x, y, GetPixel( dc, x, y ) ^ 0x00808080 );
2168|      }
2169|      break;
2170|
2171|    case 2:  /* 垂直線 */
2172|      for ( ; y < xy2; y++ ) {
2173|        if ( y & 8 )
2174|          SetPixel( dc, x, y, GetPixel( dc, x, y ) ^ 0x00808080 );
2175|      }
2176|      break;
2177|  }
2178|}
2179|
2180|
2181|/* キャプチャ範囲決定後 */
2182|void CMainFrame::OnCapture2()
2183|{
2184|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
2185|  CMainFrame*  frame = (CMainFrame*)app->m_pMainWnd;
2186|  CChildView*  view = frame->m_wndView;
2187|  HWND desktop = ::GetDesktopWindow();
2188|  HDC  desktopDC = ::GetDC( desktop );
2189|  bool  bShow = false;
2190|  char  imgWorkPath[_MAX_PATH];
2191|
2192|
2193|  /* キャプチャしてワーク用 JPEG ファイルを作成する */
2194|  {
2195|    HBITMAP  bmp;
2196|    HDC  bmpDC;
2197|    int  w, w_stride, h, bpp;
2198|    HGDIOBJ  oldBmp;
2199|    char*  buf;
2200|
2201|    /* 画面(デスクトップ全体)と、処理用ビットマップを作成する */
2202|    w = view->m_UpS.x - view->m_DownS.x + 1;
2203|    h = view->m_UpS.y - view->m_DownS.y + 1;
2204|    bpp = GetDeviceCaps( desktopDC, BITSPIXEL );
2205|    w_stride = w * ( (bpp + 7) / 8 );  w_stride = (w_stride + 3) & ~3;
2206|
2207|    if ( bpp != 16 && bpp != 24 && bpp != 32 ) {
2208|      MessageBox( "この機能は、画面が16,24,32ビットのいずれかの色数のときしか使えません" );
2209|      goto finish;
2210|    }
2211|    if ( w <= 0 )  goto  finish;
2212|
2213|
2214|    /* キャプチャする範囲をウィンドウのサイズにする */
2215|    if ( w < 8 && h < 8 ) {
2216|      POINT  pt;
2217|      int  x,y;
2218|      RECT  rc;
2219|      HWND  targetWnd;
2220|      HWND  targetWnd2;
2221|
2222|      GetCursorPos( &pt );  x = pt.x;  y = pt.y;
2223|      for ( targetWnd = ::GetTopWindow( desktop );
2224|            targetWnd != NULL;
2225|            targetWnd = ::GetNextWindow( targetWnd, GW_HWNDNEXT ) ) {
2226|        if ( targetWnd == m_CaptureArea )  continue;
2227|        if ( ! ::IsWindowVisible( targetWnd ) )  continue;
2228|        ::GetWindowRect( targetWnd, &rc );
2229|        if ( rc.left <= x && x <= rc.right && rc.top <= y && y <= rc.bottom ) {
2230|          for ( targetWnd2 = ::GetTopWindow( targetWnd );
2231|                targetWnd2 != NULL;
2232|                targetWnd2 = ::GetNextWindow( targetWnd2, GW_HWNDNEXT ) ) {
2233|            if ( ! ::IsWindowVisible( targetWnd2 ) )  continue;
2234|            ::GetWindowRect( targetWnd2, &rc );
2235|            if ( rc.left <= x && x <= rc.right && rc.top <= y && y <= rc.bottom ) {
2236|              break;
2237|            }
2238|          }
2239|          if ( targetWnd2 == NULL )  ::GetWindowRect( targetWnd, &rc );
2240|          break;
2241|        }
2242|      }
2243|      if ( targetWnd == NULL )  ::GetWindowRect( desktop, &rc );
2244|      if ( rc.left < 0 )  rc.left = 0;
2245|      if ( rc.right > GetSystemMetrics(SM_CXSCREEN)-1 )  rc.right = GetSystemMetrics(SM_CXSCREEN)-1;
2246|      if ( rc.top < 0 )  rc.top = 0;
2247|      if ( rc.bottom > GetSystemMetrics(SM_CYSCREEN)-1 )  rc.bottom = GetSystemMetrics(SM_CYSCREEN)-1;
2248|      w = rc.right - rc.left;
2249|      h = rc.bottom - rc.top;
2250|      w_stride = w * ( (bpp + 7) / 8 );  w_stride = (w_stride + 3) & ~3;
2251|      view->m_DownS.x = rc.left;
2252|      view->m_DownS.y = rc.top;
2253|
2254|      #if 0
2255|      char  s[256];
2256|      ::GetWindowText( targetWnd, s, sizeof(s) );
2257|      Errors_printf(s);
2258|      if ( targetWnd2!= NULL )   ::GetWindowText( targetWnd2, s, sizeof(s) );
2259|      Errors_printf(s);
2260|      #endif
2261|    }
2262|
2263|    /* キャプチャする */
2264|    bmp = CreateCompatibleBitmap( desktopDC, w_stride / ((bpp+7)/8), h );
2265|    bmpDC = CreateCompatibleDC( desktopDC );
2266|    oldBmp = SelectObject( bmpDC, bmp );
2267|
2268|    BitBlt( bmpDC, 0, 0, w, h,
2269|      desktopDC, view->m_DownS.x, view->m_DownS.y, SRCCOPY );
2270|    buf = (char*)malloc( w_stride * h );
2271|    GetBitmapBits( bmp, w_stride * h, buf );
2272|
2273|    /* PNGに変換する */
2274|    if ( m_bCaptureFormat == 1 ) {
2275|      strcpy( imgWorkPath, app->GetImgWorkFilePath( (long)m_hWnd ) );
2276|      StrX_chgExt( imgWorkPath, "png" );
2277|
2278|      CompressToPng( w, h, w_stride, buf, bpp, imgWorkPath );
2279|    }
2280|
2281|    /* JPEGに変換する */
2282|    else {
2283|      strcpy( imgWorkPath, app->GetImgWorkFilePath( (long)m_hWnd ) );
2284|      StrX_chgExt( imgWorkPath, "jpg" );
2285|
2286|      CompressPictureToJpeg( w, h, w_stride, buf, false, bpp, imgWorkPath );
2287|    }
2288|
2289|
2290|    /* 後始末する */
2291|    free( buf );
2292|    SelectObject( bmpDC, oldBmp );
2293|    DeleteDC( bmpDC );
2294|    DeleteObject( bmp );
2295|  }
2296|
2297|
2298|  /* ウィンドウとファイルを復帰する */
2299|  ::DestroyWindow( m_CaptureArea );
2300|  RestoreWindow( false, NULL );
2301|  bShow = true;
2302|
2303|
2304|  /* 作成した JPEG ファイルを図形としてキャンバスに追加する */
2305|  {
2306|    Rect_Ex*  rect;
2307|    ListX_ElemX*  p;
2308|
2309|    OnSelect();
2310|    m_wndSplitter.SetActivePane( 0, 0, m_wndView );
2311|    m_wndView->ResetSelect();
2312|
2313|    rect = new Rect_Ex;
2314|    rect->m_id = app->GetNewPrimID();
2315|    rect->m_bSelected = true;
2316|    Rect_init( &rect->m_Rect, 10, 10, 1, 1 );
2317|    rect->m_BorderWidth = 1;
2318|    rect->m_BorderColor = 0;
2319|    rect->m_FillColor = 0xFFFFFF;
2320|    rect->m_ShapeType = Rect_ImageShape;
2321|    rect->m_ImgPath = "";
2322|    rect->m_ImgWorkPath = imgWorkPath;
2323|    rect->m_Target = "_blank";
2324|    app->AddPrim( &app->m_file, rect );
2325|
2326|    m_wndView->m_HoldPrim = rect;
2327|    ListX_toEmptyDelete( &m_wndView->m_MultiHolds, ListX_ElemX, NULL );
2328|    p = ListX_addLastMalloc( &m_wndView->m_MultiHolds, ListX_ElemX );
2329|    p->p = m_wndView->m_HoldPrim;
2330|    rect->SetHold( true );
2331|    app->m_UndoBuf->AllocNewStep( NULL, rect->GetNewCopy( &app->m_file.m_prims ), NULL, NULL,
2332|      app->m_file.m_CurrentPageNum - app->m_file.m_StartPageNum );
2333|    m_wndView->SetMultiSelect();
2334|    m_wndView->ResetScrollAndScale();
2335|    m_wndView->Redraw( false );
2336|    SetPropMulti( &m_wndView->m_MultiHolds, m_wndView->m_HoldStrokes );
2337|  }
2338|
2339|finish:
2340|  if ( ! bShow ) {
2341|    ::DestroyWindow( m_CaptureArea );
2342|    if ( m_bVisibleBeforeCapture )
2343|      RestoreWindow( false, NULL );  /* アイコンからキャンセルしたときは、表示しない */
2344|    ::SetWindowPos( m_hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE );
2345|  }
2346|
2347|  ::ReleaseDC( desktop, desktopDC );
2348|}
2349|
2350|
2351|
2352| 
2353|/***********************************************************************
2354|  13-8. <<< [CompressToPng] ビットマップから PNG ファイルを作成する >>> 
2355|【引数】
2356|  ・int    w, h;      ビットマップの幅と高さ
2357|  ・int    w_stride;  bmpの1行のバイト数(w*bppより大きいときやアラインメントに対応するため)
2358|  ・char*  bmp;       ビットマップデータ
2359|  ・int    bpp;       1ピクセルあたりのビット数(16,24,32bpp)
2360|  ・char*  out_path;  出力するPNGファイルのパス
2361|************************************************************************/
2362|void  CMainFrame::CompressToPng( int w, int h, int w_stride, char* bmp, int bpp, const char* out_path )
2363|{
2364|  char  bmp_path[_MAX_PATH];
2365|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
2366|
2367|  strcpy( bmp_path, app->GetImgWorkFilePath( (long)m_hWnd ) );
2368|  StrX_chgExt( bmp_path, "bmp" );
2369|
2370|
2371|  /* まず BMP ファイルを作成する */
2372|  {
2373|    FILE*  f;
2374|    BITMAPFILEHEADER  head;
2375|    BITMAPINFOHEADER  info;
2376|    int  x, y, stride24 = (w * 3 + 3) & ~ 3;
2377|
2378|    f = FileX_open( bmp_path, "wb" );
2379|
2380|    head.bfType = 'B' + 'M'*256;
2381|    head.bfSize = sizeof(head) + sizeof(info) + stride24 * h;
2382|    head.bfReserved1 = 0;
2383|    head.bfReserved2 = 0;
2384|    head.bfOffBits = sizeof(head) + sizeof(info);
2385|    fwrite( &head, 1, sizeof(head), f );
2386|
2387|    info.biSize = sizeof(info);
2388|    info.biWidth = w;
2389|    info.biHeight = h;
2390|    info.biPlanes = 1;
2391|    info.biBitCount = 24;
2392|    info.biCompression = BI_RGB;
2393|    info.biSizeImage = stride24 * h;
2394|    info.biXPelsPerMeter = 0;
2395|    info.biYPelsPerMeter = 0;
2396|    info.biClrUsed = 0;
2397|    info.biClrImportant = 0;
2398|    fwrite( &info, 1, sizeof(info), f );
2399|
2400|    if ( bpp == 24 ) {
2401|      for ( y = h - 1; y >= 0; y-- )
2402|        fwrite( bmp + y * w_stride, 1, w_stride, f );
2403|    }
2404|    else if ( bpp == 32 ) {
2405|      int  c;
2406|      char*  line = (char*)malloc( stride24 );
2407|
2408|      for ( y = h - 1; y >= 0; y-- ) {
2409|        for ( x = 0; x < w; x++ ) {
2410|          c = *(unsigned long*)( bmp + y * w_stride + x * 4 );
2411|          line[x*3+0] = Color_RGB24_getB(c);
2412|          line[x*3+1] = Color_RGB24_getG(c);
2413|          line[x*3+2] = Color_RGB24_getR(c);
2414|        }
2415|        fwrite( line, 1, stride24, f );
2416|      }
2417|
2418|      free( line );
2419|    }
2420|    else {  ASSERT( bpp == 16 );
2421|      int  c;
2422|      char*  line = (char*)malloc( stride24 );
2423|
2424|      for ( y = h - 1; y >= 0; y-- ) {
2425|        for ( x = 0; x < w; x++ ) {
2426|          c = *(short*)( bmp + y * w_stride + x * 2 );
2427|          c = Color_RGB16_getRGB24( c );
2428|          line[x*3+0] = Color_RGB24_getB(c);
2429|          line[x*3+1] = Color_RGB24_getG(c);
2430|          line[x*3+2] = Color_RGB24_getR(c);
2431|        }
2432|        fwrite( line, 1, stride24, f );
2433|      }
2434|
2435|      free( line );
2436|    }
2437|
2438|    fclose( f );
2439|  }
2440|
2441|  /* PNGに変換する */
2442|  {
2443|    HINSTANCE  DLL;
2444|    typedef  int  (WINAPI *BmpToPng_F)(char*, const char*, char* );
2445|    BmpToPng_F  pBmpToPng;
2446|    char  plugin_path[_MAX_PATH];
2447|    char  cwd[_MAX_PATH];
2448|    int  ret;
2449|
2450|    _getcwd( cwd, sizeof(cwd) );
2451|
2452|    strcpy( plugin_path, "system\\plugin" );
2453|    StrX_getExeFullPath( plugin_path, plugin_path, sizeof(plugin_path) );
2454|
2455|    _chdir( plugin_path );  /* 拡張子が DLLのときに必要 */
2456|    DLL = LoadLibrary( "PngSaver.dll" );
2457|    _chdir( cwd );
2458|
2459|    pBmpToPng = (BmpToPng_F)GetProcAddress( DLL, "BmpToPng" );
2460|    ret = pBmpToPng( bmp_path, out_path, "9" );
2461|
2462|    FreeLibrary( DLL );
2463|  }
2464|
2465|  remove( bmp_path );
2466|}
2467| 
2468|/***********************************************************************
2469|  13-9. <<< [CMainFrame::Load] ファイルを開く >>> 
2470|************************************************************************/
2471|void  CMainFrame::Load( const char* path, bool bUpdateRecent )
2472|{
2473|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
2474|  char  path2[_MAX_PATH];
2475|  SVGCat_Page*  page;
2476|  CWaitCursor  wa;
2477|
2478|  c_try {
2479|    if ( app->m_path[0] != '\0' && ! app->m_bTaskTray )
2480|      app->SetRecentFile( app->m_path );
2481|    strcpy( app->m_path, path );
2482|    m_wndView->ResetScrollAndScale();
2483|    m_wndView->m_bEnableOnPaint = false;  /* DrawBackBitmap を何回も呼ばないため */
2484|    #ifdef  SVGCats_NewFileAccess
2485|      app->Load2( path );
2486|    #else
2487|      app->Load( path );
2488|    #endif
2489|    m_wndView->m_bEnableOnPaint = true;
2490|
2491|
2492|    /* ツリーを作り直す */
2493|    {
2494|      CTreeCtrl*  tree = &m_Left->GetTreeCtrl();
2495|      SVGCat_Page*  page;
2496|
2497|      tree->DeleteAllItems();
2498|      page = ListX_getFirst( &app->m_file.m_pages, SVGCat_Page );
2499|      if ( app->m_file.m_StartPageNum == 0 )  page = ListX_Elem_getNextT( page, SVGCat_Page );
2500|      LoadTree( tree, page, TVI_ROOT );
2501|      tree->Select( tree->GetChildItem( TVI_ROOT ), TVGN_CARET );
2502|
2503|      if ( ListX_getN( &app->m_file.m_pages, SVGCat_Page ) + app->m_file.m_StartPageNum - 1 == 1 ||
2504|           m_bViewMode || m_bScopeMode )
2505|        { m_wndSplitter.SetColumnInfo( 0, 0, 0 );  app->m_SplitMode = 1; }
2506|      else
2507|        { m_wndSplitter.SetColumnInfo( 0, app->m_SplitX, 0 );  app->m_SplitMode = 0; }
2508|      m_wndSplitter.RecalcLayout();
2509|    }
2510|
2511|    /* キャンバスを初期化する */
2512|    m_wndView->m_bBitmap = false;
2513|    if ( m_hWnd != NULL ) {
2514|      m_wndView->m_HoldPrim = NULL;
2515|      ListX_toEmptyDelete( &m_wndView->m_MultiHolds, ListX_ElemX, NULL );
2516|    }
2517|    m_wndView->SetDrawnParam( &app->m_file.m_prims );
2518|    app->Load2( &app->m_file.m_prims );
2519|    for ( ListX_forEach( &app->m_file.m_pages, &page, SVGCat_Page ) ) {
2520|      m_wndView->SetDrawnParam( &page->prims );
2521|      app->Load2( &page->prims );
2522|    }
2523|    if ( m_hWnd != NULL ) {
2524|      UpdateWindowText();
2525|      m_wndView->m_Zoom = 100;
2526|      m_wndView->SetScrollSize();
2527|      m_wndView->DrawBackBitmap();
2528|      m_wndView->Invalidate( FALSE );
2529|    }
2530|    if ( bUpdateRecent )
2531|      app->SetRecentFile( app->m_path );
2532|    if ( m_hWnd != NULL )
2533|      ResetProp();
2534|
2535|    /* バックアップファイルの名前も変える */
2536|    strcpy( path2, app->m_backPath );
2537|    app->ChangeBackup();
2538|    MoveFile( path2, app->m_backPath );
2539|  }
2540|  c_catch ( Errors_Msg*, msg ) {
2541|    if ( msg->code != CSVGCatApp_Err_Format )  c_throw_again();
2542|    New();
2543|  } c_end_catch;
2544|
2545|  SetDefaultMode();
2546|
2547|  /* Tablet PC モジュールがないときに、インクがあるときは、表示できない警告をする */
2548|  if ( m_wndView->m_InkOverlay == NULL ) {
2549|    int  iPage, nPage;
2550|
2551|    nPage = ListX_getN( &app->m_file.m_pages, SVGCat_Page );
2552|    for ( iPage = 0; iPage < nPage; iPage++ ) {
2553|      if ( FileX_getSize( app->GetInkWorkFilePath( app->m_file.m_id,
2554|            iPage + app->m_file.m_StartPageNum, IRO_MaskPen ) ) > 0 ||
2555|           FileX_getSize( app->GetInkWorkFilePath( app->m_file.m_id,
2556|            iPage + app->m_file.m_StartPageNum, IRO_MaskPen ) ) > 0 ) {
2557|        MessageBox( app->m_bJapanese ?
2558|          "このファイルにインクデータがありますが表示できません。\r\n"
2559|          "SVG Cats で表示/加工するには、Tablet PC モジュールを含んでいる"
2560|          "Windows Journal Viewer などをインストールしてください。"
2561|          "ただし、インクデータを見るだけなら SVG ビューアでできます。" :
2562|          "Ink data in this file can not display.\r\n"
2563|          "Install Windows Journal Viewer etc. including Tablet PC module,"
2564|          " if you want to display or edit ink on SVG Cats." );
2565|        break;
2566|      }
2567|    }
2568|  }
2569|}
2570|
2571|
2572| 
2573|/***********************************************************************
2574|  13-10. <<< [CMainFrame::LoadTree] tree に page とその子や次の項目を追加する >>> 
2575|【引数】
2576|  ・CTreeCtrl*   tree;  追加対象のツリー
2577|  ・SVGCat_Page* page;  追加する先頭のツリー(兄弟項目は next==NULL まで)
2578|  ・HTREEITEM  parent;  追加位置の親のツリー項目
2579|  ・HTREEITEM  after;   追加位置の前のツリー項目(NULL=先頭に追加)
2580|  ・HTREEITEM  返り値;  追加した先頭のツリー項目
2581|************************************************************************/
2582|HTREEITEM  CMainFrame::LoadTree( CTreeCtrl* tree, SVGCat_Page* page, HTREEITEM parent, HTREEITEM after )
2583|{
2584|  //CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
2585|  HTREEITEM  firstItem = NULL;
2586|  HTREEITEM  item;
2587|  //CString  num;  /* 追加削除したときに全て修正する必要があるため却下 */
2588|
2589|  if ( after == NULL )  after = TVI_FIRST;
2590|  while ( page != NULL ) {
2591|    //num.Format( "%d", ListX_getI( &app->m_file.m_pages, page ) + app->m_file.m_StartPageNum );
2592|    item = tree->InsertItem( page->title, parent, after );
2593|    if ( firstItem == NULL )  firstItem = item;
2594|    tree->SetItemData( item, (long)page );
2595|    if ( page->firstChild != NULL ) {
2596|      LoadTree( tree, page->firstChild, item );
2597|    }
2598|    after = item;
2599|    page = page->next;
2600|  }
2601|
2602|  return  firstItem;
2603|}
2604|
2605|
2606| 
2607|/***********************************************************************
2608|  13-11. <<< [CMainFrame::OnSaveOv] 上書き保存を選んだときの処理 >>> 
2609|************************************************************************/
2610|void CMainFrame::OnSaveOv()
2611|{
2612|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
2613|  CString  msg2, msg3;
2614|  bool  bOverReadonly = false;
2615|
2616|  if ( app->m_bJapanese ) {
2617|    msg2.LoadString( IDS_ReadOnlyOver );
2618|    msg3.LoadString( IDS_SetReadOnlyAgain );
2619|  }
2620|  else {
2621|    msg2.LoadString( IDS_ReadOnlyOver_E );
2622|    msg3.LoadString( IDS_SetReadOnlyAgain_E );
2623|  }
2624|
2625|  m_wndView->OnFinishPrimMove();
2626|  m_wndView->ResetSelect();
2627|
2628|  if ( app->m_path[0] == '\0' ) {
2629|    OnSaveAs();
2630|    if ( app->m_path[0] != '\0' && ! app->m_bTaskTray  )
2631|      app->SetRecentFile( app->m_path );
2632|  }
2633|  else {
2634|    CWaitCursor  wa;
2635|    if ( FileX_isExist( app->m_path ) && GetFileAttributes( app->m_path ) &  FILE_ATTRIBUTE_READONLY ) {
2636|      if ( MessageBox( msg2, NULL, MB_YESNO ) == IDNO )  return;
2637|      FileX_setReadOnly( app->m_path, false );
2638|      bOverReadonly = true;
2639|    }
2640|
2641|    app->Save( app->m_path, false );
2642|
2643|    if ( bOverReadonly ) {
2644|      if ( MessageBox( msg3, app->m_path, MB_YESNO ) == IDYES )
2645|        FileX_setReadOnly( app->m_path, true );
2646|    }
2647|  }
2648|
2649|  if ( m_wndView->m_HoldPrim == NULL )  ResetProp();
2650|  else  SetPropMulti( &m_wndView->m_MultiHolds, m_wndView->m_HoldStrokes );
2651|}
2652|
2653|
2654| 
2655|/***********************************************************************
2656|  13-12. <<< [CMainFrame::OnSaveAs] 名前を付けて保存を選んだときの処理 >>> 
2657|************************************************************************/
2658|void CMainFrame::OnSaveAs()
2659|{
2660|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
2661|
2662|  SaveAsImp( ( app->m_path[0] == '\0' ? NULL : app->m_path ), true );
2663|}
2664|
2665|
2666|void CMainFrame::OnSaveAsReadOnly()
2667|{
2668|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
2669|
2670|  if ( SaveAsImp( ( app->m_path[0] == '\0' ? NULL : app->m_path ), true ) == IDOK ) {
2671|    FileX_setReadOnly( app->m_path, true );
2672|  }
2673|}
2674|
2675|void CMainFrame::OnSaveForMail()
2676|{
2677|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
2678|
2679|  SaveAsImp( ( app->m_path[0] == '\0' ? NULL : app->m_path ), true, false, true );
2680|}
2681|
2682|void CMainFrame::OnSaveTemplate()
2683|{
2684|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
2685|  int  i;
2686|  char  folder[_MAX_PATH];
2687|  char  path[_MAX_PATH];
2688|
2689|  StrX_getExeFullPath( folder, _template_path, sizeof(folder) );
2690|
2691|  for ( i = 1; ; i++ ) {
2692|    sprintf( path, "%s\\template%d.svgz", folder, i );
2693|    if ( ! FileX_isExist( path ) ) {
2694|      sprintf( path, "%s\\template%d.svg", folder, i );
2695|      if ( ! FileX_isExist( path ) )
2696|        break;
2697|    }
2698|  }
2699|
2700|  if ( SaveAsImp( path, true, true ) == IDOK ) {
2701|    FileX_setReadOnly( app->m_path, true );
2702|  }
2703|}
2704|
2705|/* bool bNoConfReadOnly;  読み込み専用属性に関する確認を行わないかどうか */
2706|int  CMainFrame::SaveAsImp( const char* defPath, bool bResetSelect, bool bNoConfReadOnly,
2707|  bool bForMail )
2708|{
2709|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
2710|  CString  msg1, msg2, msg3;
2711|  char  path[_MAX_PATH];
2712|  int  ret;
2713|  bool  bOverReadonly = false;
2714|
2715|  if ( defPath == NULL ) {
2716|    GetDefaultFName( path );
2717|    defPath = path;
2718|  }
2719|  else {
2720|    strcpy( path, defPath );  ret = 0;
2721|    while ( FileX_isExist( path ) ) {
2722|      ret++;
2723|      *( StrX_refExt( (char*)defPath ) - 1 ) = '\0';
2724|      sprintf( path, "%s-%d.%s", defPath, ret, strchr( defPath, '\0' ) + 1 );
2725|    }
2726|    defPath = path;
2727|  }
2728|  CFileDialog  dlg( FALSE, StrX_refExt( defPath ), defPath, NULL,
2729|                    app->m_bJapanese ? _svg_write_filter : _svg_write_filterE );
2730|
2731|  /* メッセージを設定する */
2732|  if ( app->m_bJapanese ) {
2733|    msg1.LoadString( IDS_SaveOver );
2734|    msg2.LoadString( IDS_ReadOnlyOver );
2735|    msg3.LoadString( IDS_SetReadOnlyAgain );
2736|  }
2737|  else {
2738|    msg1.LoadString( IDS_SaveOver_E );
2739|    msg2.LoadString( IDS_ReadOnlyOver_E );
2740|    msg3.LoadString( IDS_SetReadOnlyAgain_E );
2741|  }
2742|
2743|  if ( bResetSelect ) {
2744|    m_wndView->OnFinishPrimMove();
2745|    m_wndView->ResetSelect();
2746|  }
2747|
2748|  #ifdef  NDEBUG
2749|    dlg.m_ofn.Flags &= ~OFN_ENABLEHOOK;  /* Win2000以降の新しいファイルダイアログにする */
2750|  #endif
2751|  dlg.m_ofn.lpstrInitialDir = app->m_SaveFolderPath;
2752|
2753|  while ( (ret = dlg.DoModal()) == IDOK ) {
2754|    if ( app->m_path[0] != '\0' && ! app->m_bTaskTray )
2755|      app->SetRecentFile( app->m_path );
2756|    strcpy( path, dlg.GetPathName() );
2757|    if ( dlg.m_ofn.nFilterIndex == 1 )  StrX_chgExt( path, "svg" );
2758|    else if ( dlg.m_ofn.nFilterIndex == 2 )  StrX_chgExt( path, "svgz" );
2759|
2760|    if ( FileX_isExist( path ) ) {
2761|      int  r = MessageBox( msg1, path, MB_YESNO | MB_ICONWARNING | MB_DEFBUTTON2 );
2762|
2763|      if ( r == IDNO )  continue;
2764|
2765|      if ( GetFileAttributes( path ) &  FILE_ATTRIBUTE_READONLY ) {
2766|        if ( ! bNoConfReadOnly && MessageBox( msg2, NULL, MB_YESNO ) == IDNO )  continue;
2767|        FileX_setReadOnly( path, false );
2768|        bOverReadonly = true;
2769|      }
2770|    }
2771|
2772|    /* 保存する */
2773|    CWaitCursor  wa;
2774|
2775|    if ( bForMail ) {
2776|      SVGCat_Page*  page;
2777|      ListX_ElemX*  p;
2778|
2779|      for ( ListX_forEach( &app->m_file.m_prims, &p, ListX_ElemX ) ) {
2780|        if ( ((CadPrim*)p->p)->GetTypeID() == Rect_Ex_TypeID ) {
2781|          ((Rect_Ex*)p->p)->m_bEmbedImg = true;
2782|        }
2783|      }
2784|      for ( ListX_forEach( &app->m_file.m_pages, &page, SVGCat_Page ) ) {
2785|        for ( ListX_forEach( &page->prims, &p, ListX_ElemX ) ) {
2786|          if ( ((CadPrim*)p->p)->GetTypeID() == Rect_Ex_TypeID ) {
2787|            ((Rect_Ex*)p->p)->m_bEmbedImg = true;
2788|          }
2789|        }
2790|      }
2791|    }
2792|
2793|    app->Save( path, false );
2794|
2795|    StrX_cpyFolder( app->m_SaveFolderPath, path );
2796|    app->SaveSVGCatsIni( false );
2797|
2798|
2799|    /* バックアップファイルの名前も変える */
2800|    strcpy( path, app->m_backPath );
2801|    app->ChangeBackup();
2802|    MoveFile( path, app->m_backPath );
2803|
2804|    if ( bOverReadonly ) {
2805|      if ( bNoConfReadOnly || MessageBox( msg3, app->m_path, MB_YESNO | MB_DEFBUTTON2 ) == IDNO )
2806|        FileX_setReadOnly( app->m_path, true );
2807|    }
2808|
2809|    break;
2810|  }
2811|
2812|  if ( m_wndView->m_HoldPrim == NULL )  ResetProp();
2813|  else  SetPropMulti( &m_wndView->m_MultiHolds, m_wndView->m_HoldStrokes );
2814|
2815|  return  ret;
2816|}
2817|
2818|
2819| 
2820|/***********************************************************************
2821|  13-13. <<< [CMainFrame::OnSaveAsImage] ページ全体を画像で出力する(手動) >>> 
2822|************************************************************************/
2823|void CMainFrame::OnSaveAsImage()
2824|{
2825|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
2826|  int  i, n;
2827|  int  iMakeFolder;
2828|  int  iOutMin, iOutMax;
2829|  char  path[_MAX_PATH];
2830|  char  path2[_MAX_PATH];
2831|  char  folderPath[_MAX_PATH];
2832|  char  s[_MAX_PATH];
2833|  char  app_fname[_MAX_PATH];
2834|  bool  bOver;
2835|  bool  bPNG;
2836|
2837|  n = SVGCat_File_getMaxPageNum( &app->m_file );
2838|  strcpy( app_fname, StrX_refFName( app->m_path ) );  StrX_chgExt( app_fname, "" );
2839|
2840|
2841|  /* 出力する範囲を入力する */
2842|  if ( n > 1 ) {
2843|    COutPageDlg  dlg;
2844|
2845|    dlg.m_iOutMin = 1;
2846|    dlg.m_iOutMax = n;
2847|    dlg.m_bPNG = ( app->m_DefaultImageType == 1 );
2848|    if ( dlg.DoModal() == IDCANCEL )  return;
2849|
2850|    if ( dlg.m_bAll ) {
2851|      iOutMin = 1;  iOutMax = n;
2852|    }
2853|    else {
2854|      iOutMin = dlg.m_iOutMin;  iOutMax = dlg.m_iOutMax;
2855|      if ( iOutMin < 1 )  iOutMin = 1;
2856|      if ( iOutMax > n )  iOutMax = n;
2857|      if ( iOutMin > iOutMax )  { int  i = iOutMin;  iOutMin = iOutMax;  iOutMax = i; }
2858|    }
2859|    bPNG = (dlg.m_bPNG != 0);
2860|  }
2861|  else
2862|    { iOutMin = 1;  iOutMax = 1;  bPNG = ( app->m_DefaultImageType == 1 ); }
2863|
2864|
2865|  /* ダイアログを作成する */
2866|  sprintf( path, "%s.jpg", app_fname );
2867|  if ( bPNG )  StrX_chgExt( path, "png" );
2868|
2869|  CFileDialog  dlg( FALSE, ( bPNG ? "png" : "jpg" ), path, OFN_HIDEREADONLY | OFN_EXPLORER,
2870|                    app->m_bJapanese ? _img2_filter : _img2_filterE );
2871|  #ifdef  NDEBUG
2872|    dlg.m_ofn.Flags &= ~OFN_ENABLEHOOK;  /* Win2000以降の新しいファイルダイアログにする */
2873|  #endif
2874|  dlg.m_ofn.lpstrInitialDir = app->m_SaveFolderPath;
2875|  dlg.m_ofn.nFilterIndex = ( bPNG ? 1 : 2 );
2876|
2877|
2878|  /* パスを入力する */
2879|  for (;;) {
2880|    bOver = false;
2881|    if ( dlg.DoModal() == IDOK ) {
2882|
2883|      /* フォルダを作成するか確認する */
2884|      if ( n >= 2 ) {
2885|        strcpy( folderPath, dlg.GetPathName() );
2886|        StrX_chgExt( folderPath, "" );
2887|        iMakeFolder = MessageBox( ( FileX_isDir( folderPath ) ?
2888|             CString("既に存在するフォルダ[") + StrX_refFName( folderPath ) + "]の中に" :
2889|             CString("新しいフォルダ[") + StrX_refFName( folderPath ) + "]を作成して、その中に" ) +
2890|             "画像ファイルをまとめますか?\r\n"
2891|             "「いいえ」を選ぶと、" + ( FileX_isDir( folderPath ) ?
2892|             "フォルダの外に" : "フォルダを作成しないで" ) + "画像ファイルを作成します。",
2893|             "作成位置の確認", MB_YESNOCANCEL );
2894|        if ( iMakeFolder == IDNO )  StrX_cutFName( folderPath );
2895|        else if ( iMakeFolder == IDCANCEL )  continue;
2896|        strcpy( path, folderPath );
2897|        StrX_addFName( path, StrX_refFName( (const char*)dlg.GetPathName() ) );
2898|      }
2899|      else {
2900|        strcpy( path, dlg.GetPathName() );
2901|        iMakeFolder = IDNO;
2902|      }
2903|
2904|      bPNG = (dlg.m_ofn.nFilterIndex == 1 );
2905|      StrX_chgExt( path, ( bPNG ? "png" : "jpg" ) );
2906|      FileX_mkdir2( path, true );
2907|
2908|      StrX_cpyFolder( app->m_SaveFolderPath, path );
2909|      app->m_DefaultImageType = ( bPNG ? 1 : 2 );
2910|      app->SaveSVGCatsIni( false );
2911|
2912|      for ( i = 1; i <= n; i++ ) {
2913|        if ( i < iOutMin || i > iOutMax )  continue;
2914|
2915|        sprintf( s, "画像出力中 (%d/%d) ...", i - iOutMin + 1, iOutMax - iOutMin + 1 );
2916|        SetWindowText( s );
2917|
2918|        if ( n == 1 )  sprintf( path2, path );
2919|        else  StrX_addNumInFName( path2, path, i );
2920|
2921|        /* 上書き確認する */
2922|        if ( ! bOver && FileX_isExist( path2 ) ) {
2923|          if ( n == 1 )  sprintf( s, "%s は既に存在します。\r\n上書きしますか?", path2 );
2924|          else  sprintf( s, "%s などは既に存在します。\r\nすべて上書きしますか?", path2 );
2925|          if ( MessageBox( s, NULL, MB_YESNO | MB_DEFBUTTON2 ) == IDNO )
2926|            goto to_be_continued;
2927|          bOver = true;
2928|        }
2929|
2930|        /* 保存する */
2931|        m_wndView->PaintToImage( i, path2 );
2932|      }
2933|      UpdateWindowText();
2934|    }
2935|    if ( iMakeFolder == IDYES )  WinX_openFolder( folderPath );
2936|    break;
2937|to_be_continued:;
2938|  }
2939|}
2940|
2941| 
2942|/***********************************************************************
2943|  13-14. <<< [CMainFrame::SaveToImage] ページ全体を画像で出力する(自動) >>> 
2944|【引数】
2945|  ・char*  out_path;  出力パス(複数ページのときは、(2)のような番号が自動でつく)
2946|  ・int mode;         'j'=JPEG, 'p'=PNG
2947|【補足】
2948|・CMainFrame::OnSaveAsImage と異なり、出力ファイルの上書きを確認しません。
2949|************************************************************************/
2950|void CMainFrame::SaveToImage( const char* out_path, int mode )
2951|{
2952|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
2953|  int  i, n;
2954|  char  s[_MAX_PATH];
2955|  char  path2[_MAX_PATH];
2956|
2957|  n = SVGCat_File_getMaxPageNum( &app->m_file );
2958|
2959|  for ( i = 1; i <= n; i++ ) {
2960|
2961|    sprintf( s, "画像出力中 (%d/%d) ...", i, n );
2962|    SetWindowText( s );
2963|
2964|    if ( n == 1 )  sprintf( path2, out_path );
2965|    else  StrX_addNumInFName( path2, out_path, i );
2966|
2967|    m_wndView->PaintToImage( i, path2 );
2968|  }
2969|  UpdateWindowText();
2970|}
2971|
2972|
2973| 
2974|/***********************************************************************
2975|  13-15. <<< [CMainFrame::GetDefaultFName] デフォルトのファイルパスを得る >>> 
2976|************************************************************************/
2977|void  CMainFrame::GetDefaultFName( char* path )
2978|{
2979|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
2980|  int  i, n;
2981|  char  alphaNum[2] = { '\0','\0' };
2982|
2983|  for ( i = 0;; i++ ) {
2984|    sprintf( path, "\\%s %s", app->m_bJapanese ? "メモ" : "memo",
2985|      TimeDate_getNowStrF( "%y%m%d.svg" ) );
2986|    n = i;
2987|    for (;;) {
2988|      if ( n > 0 ) {
2989|        alphaNum[0] = ( (n-1) % 26) + 'A';
2990|        StrX_ins( path + 12, alphaNum );
2991|      }
2992|      if ( n <= 26 )  break;
2993|      n = (n-1) / 26;
2994|    }
2995|
2996|    StrX_ins( path, WinX_getDesktopPath() );
2997|    if ( ! FileX_isExist( path ) ) {
2998|      StrX_chgExt( path, "svgz" );
2999|      if ( ! FileX_isExist( path ) ) {
3000|        StrX_chgExt( path, "" );
3001|        break;
3002|      }
3003|    }
3004|  }
3005|}
3006|
3007|
3008| 
3009|/***********************************************************************
3010|  13-16. <<< [CMainFrame::OnRenameOrMove] 編集中のファイルの名前を変える >>> 
3011|************************************************************************/
3012|void CMainFrame::OnRenameOrMove()
3013|{
3014|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
3015|
3016|  if ( app->m_path[0] == '\0' )  OnSaveAs();
3017|  else {
3018|    char  path[_MAX_PATH];
3019|
3020|    strcpy( path, app->m_path );
3021|    if ( SaveAsImp( app->m_path, true ) == IDOK ) {
3022|      remove( path );
3023|      app->RemoveNoExistRecentFile();
3024|      SetRecentFileMenu();
3025|
3026|      if ( app->m_bTaskTray )  OnTaskTray();
3027|
3028|      if ( app->m_bNewTaskTray ) {
3029|        app->m_bNewTaskTray = false;
3030|        strcpy( path, StrX_argv0 );
3031|        strcat( path, " -n" );
3032|        WinExec( path, SW_SHOW );
3033|      }
3034|    }
3035|  }
3036|}
3037| 
3038|/***********************************************************************
3039|  13-17. <<< [CMainFrame::OnThrowToTrash] 編集中のファイルをごみ箱へ捨てる >>> 
3040|************************************************************************/
3041|void CMainFrame::OnThrowToTrash()
3042|{
3043|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
3044|  char  path[_MAX_PATH];
3045|
3046|  if ( m_Timer != 0 )  KillTimer( m_Timer );
3047|
3048|  if ( MessageBox( "現在編集しているファイルをごみ箱へ移動しますか?",
3049|       "削除の確認", MB_YESNO | MB_DEFBUTTON2 | MB_ICONEXCLAMATION ) == IDYES ) {
3050|
3051|    CWaitCursor  wa;
3052|
3053|    if ( app->m_path[0] == '\0' ) {
3054|      GetDefaultFName( app->m_path );
3055|      app->Save( app->m_path, false );
3056|    }
3057|
3058|    strcpy( path, app->m_path );
3059|    New();
3060|    WinX_throwToTrash( m_hWnd, path );
3061|
3062|    if ( app->m_bTaskTray )  OnTaskTray();
3063|    OnClose();
3064|    return;
3065|  }
3066|  app->RemoveNoExistRecentFile();
3067|  SetRecentFileMenu();
3068|
3069|  if ( app->m_BackupInterval > 0 )
3070|    m_Timer = SetTimer( CMainFrame_Timer_Backup, 60*1000*app->m_BackupInterval, NULL );
3071|  else
3072|    m_Timer = 0;
3073|}
3074| 
3075|/***********************************************************************
3076|  13-18. <<< [CMainFrame::OnLowerPath] パスは小文字にするを選んだときの処理 >>> 
3077|************************************************************************/
3078|void CMainFrame::OnLowerPath()
3079|{
3080|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
3081|
3082|  app->m_bLowerPath = ! app->m_bLowerPath;
3083|  app->SaveSVGCatsIni();
3084|}
3085|
3086|
3087| 
3088|/***********************************************************************
3089|  13-19. <<< [CMainFrame::OnSaveHtml] フレームHTMLファイルを出力を選んだときの処理 >>> 
3090|************************************************************************/
3091|void CMainFrame::OnSaveHtml()
3092|{
3093|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
3094|  CString  s;
3095|
3096|  if ( app->m_path[0] == '\0' ) {
3097|    if ( app->m_bJapanese )  s.LoadString( IDS_NeedFName );
3098|    else  s.LoadString( IDS_NeedFName_E );
3099|
3100|    MessageBox( s, NULL, MB_OK );
3101|  }
3102|  else {
3103|    CHtmlSelDlg  dlg;
3104|    char  path[_MAX_PATH];
3105|    char  svg_fname[_MAX_PATH];
3106|    char  title[_MAX_PATH];
3107|    int   type;
3108|
3109|    StrX_cpyFName( svg_fname, app->m_path );
3110|
3111|    strcpy( path, app->m_path );
3112|    StrX_chgExt( path, "htm" );
3113|    if ( app->m_bLowerPath )
3114|      StrX_cpyLower( path, path );
3115|
3116|    StrX_cpyFName( title, app->m_path );
3117|    StrX_chgExt( title, "" );
3118|
3119|    /*
3120|    type = ( MessageBox( app->m_bJapanese ? "作成する HTML にページ切替のボタンをつけますか?" :
3121|      "Do you want to set page changing buttons?", StrX_refFName( path ), MB_YESNO ) == IDYES ?
3122|      1 : 2 );
3123|    */
3124|    if ( dlg.DoModal() == IDOK ) {
3125|      if ( dlg.m_iType == IDC_WallType )  type = 1;
3126|      else if ( dlg.m_iType == IDC_PresenType )  type = 2;
3127|      else  type = 3;
3128|      app->SaveHtml( path, svg_fname, title, type );
3129|
3130|      if ( app->m_bJapanese )  s.LoadString( IDS_DoneOutHtml );
3131|      else  s.LoadString( IDS_DoneOutHtml_E );
3132|      if ( MessageBox( s, NULL, MB_YESNO ) == IDYES )
3133|        WinX_openIE( path );
3134|    }
3135|  }
3136|}
3137|
3138|
3139| 
3140|/***********************************************************************
3141|  13-20. <<< [CMainFrame::TakeBackup] バックアップを取る >>> 
3142|************************************************************************/
3143|void  CMainFrame::TakeBackup()
3144|{
3145|  if ( m_wndView->m_InputML != NULL ) {
3146|    m_wndView->m_InputML->save();
3147|    ((Text_Box*)m_wndView->m_HoldPrim)->m_Text = m_wndView->m_InputML->m_Text;
3148|    m_wndView->Redraw( true );
3149|  }
3150|
3151|  {
3152|    CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
3153|    IInkDisp*  ink;
3154|    VARIANT_BOOL  bDirty;
3155|    HRESULT  hr;
3156|    int  nRedraw = 0;
3157|
3158|    if ( m_wndView->m_InkOverlay != NULL ) {
3159|      hr = m_wndView->m_InkOverlay->get_Ink( &ink );
3160|      if ( hr != 0 )  error();
3161|      hr = ink->get_Dirty( &bDirty );
3162|      if ( hr != 0 )  error();
3163|
3164|      for (;;) {
3165|        c_try {
3166|          FileX_backup( app->m_backPath );
3167|          app->Save( app->m_backPath, true );
3168|          nRedraw = 0;
3169|        }
3170|        c_catch ( Errors_Msg*, msg ) {
3171|          if ( msg->code != SVGCat_Err_NotSetDrawParam || nRedraw > 0 )
3172|            c_throw_again();
3173|          nRedraw++;
3174|        } c_end_catch;
3175|
3176|        if ( nRedraw == 0 )  break;
3177|
3178|        m_wndView->DrawAll( &m_wndView->m_BitmapDC, true );
3179|      }
3180|
3181|      hr = ink->put_Dirty( bDirty );
3182|      if ( hr != 0 )  error();
3183|
3184|      hr = ink->Release();  ink = NULL;
3185|      // if ( hr > 5 )  error();  // ロープを使っているときは多くなるのでチェックしない
3186|    }
3187|  }
3188|}
3189| 
3190|/***********************************************************************
3191|  13-21. <<< [CMainFrame::OnOpenBackup] バックアップ・フォルダを開く >>> 
3192|************************************************************************/
3193|void CMainFrame::OnOpenBackup()
3194|{
3195|  char  path[_MAX_PATH];
3196|
3197|  StrX_getExeFullPath( path, _backup_path, sizeof(path) );
3198|  WinX_openFolder( path );
3199|}
3200| 
3201|/***********************************************************************
3202|  13-22. <<< [CMainFrame::OnTimer] 定期バックアップなど、時間が来たときの処理 >>> 
3203|************************************************************************/
3204|void CMainFrame::OnTimer(UINT nIDEvent)
3205|{
3206|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
3207|
3208|  if ( m_Timer != 0 )  { KillTimer( m_Timer );  m_Timer = 0; }
3209|
3210|  switch ( nIDEvent ) {
3211|    case  CMainFrame_Timer_Backup:
3212|      TakeBackup();
3213|      m_Timer = SetTimer( CMainFrame_Timer_Backup, 60*1000*app->m_BackupInterval, NULL );
3214|      break;
3215|
3216|    case  CMainFrame_Timer_SingleDblClick: {
3217|      CPoint  pt, sc;
3218|      POINT   curPt;
3219|
3220|      KillTimer( m_wndView->m_SingleDblClickTimer );
3221|
3222|      GetCursorPos( &curPt );
3223|      m_wndView->ScreenToClient( &curPt );
3224|
3225|      m_wndView->m_SingleDblClickTimer = 0;
3226|      pt.x = m_wndView->m_DownX;
3227|      pt.y = m_wndView->m_DownY;
3228|
3229|      pt.x = pt.x * m_wndView->m_Zoom / 100;
3230|      pt.y = pt.y * m_wndView->m_Zoom / 100;
3231|      pt += m_wndView->m_MinusOffset;
3232|      sc = m_wndView->GetScrollPosition();
3233|      pt -= sc;
3234|
3235|      if ( abs(curPt.x - pt.x) + abs(curPt.y - pt.y) < 16 ) {
3236|        m_wndView->OnLButtonDblClk( 0, pt );
3237|        m_wndView->OnLButtonUp( 0, pt );
3238|      }
3239|      break;
3240|    }
3241|
3242|    case  CMainFrame_Timer_DrawRope:
3243|      m_wndView->OnDrawRopeTiming();
3244|      break;
3245|  }
3246|  CFrameWnd::OnTimer(nIDEvent);
3247|}
3248|
3249|
3250| 
3251|/***********************************************************************
3252|  13-23. <<< [CMainFrame::OnTreeSelchanged] ツリービューの選択を変更したときの処理 >>> 
3253|************************************************************************/
3254|void  CMainFrame::OnTreeSelchanged()
3255|{
3256|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
3257|  CTreeCtrl*  tree;
3258|  HTREEITEM   item;
3259|  SVGCat_Page*  page;
3260|  int  iPage;
3261|
3262|  if ( app->m_file.m_CurrentPageNum == -1 )  return;
3263|
3264|  tree = &m_Left->GetTreeCtrl();
3265|  item = tree->GetSelectedItem();
3266|  if ( item == NULL )  return;
3267|  page = (SVGCat_Page*)tree->GetItemData( item );
3268|  iPage = ListX_getI( &app->m_file.m_pages, page );
3269|  if ( iPage == -1 ) {
3270|    // MessageBox("debug");
3271|    return;
3272|  }
3273|
3274|  if ( iPage != app->m_file.m_CurrentPageNum - app->m_file.m_StartPageNum &&
3275|       ! m_wndView->m_bDisableSwapRec ) {
3276|    m_wndView->m_ZoomSwitchZoom = m_wndView->m_Zoom;
3277|    m_wndView->m_ZoomSwitchOffset = m_wndView->GetScrollPosition();
3278|    m_wndView->m_ZoomSwitchMode = m_wndView->m_ZoomMode;
3279|    m_wndView->m_ZoomSwitchPage = app->m_file.m_CurrentPageNum;
3280|  }
3281|
3282|  m_wndView->ResetSelect();
3283|  app->ChgPage( &app->m_file, iPage + app->m_file.m_StartPageNum );
3284|  m_wndView->Invalidate( FALSE );
3285|  m_wndView->SetScrollSize();
3286|  m_wndView->ResetScrollPos();
3287|  UpdateWindowText();
3288|  ResetProp();
3289|
3290|  if ( app->m_SplitMode == 2 )
3291|    OnSideByTree();
3292|}
3293|
3294|
3295| 
3296|/***********************************************************************
3297|  13-24. <<< [CMainFrame::OnTreeLButtonDown] ツリービューの項目をクリックしたときの処理 >>> 
3298|************************************************************************/
3299|void  CMainFrame::OnTreeLButtonDown( UINT nFlags, CPoint point )
3300|{
3301|  m_wndView->m_bDisableSwapRec = false;
3302|}
3303|
3304| 
3305|/***********************************************************************
3306|  13-25. <<< [CMainFrame::OnTreeBeginDrag] ツリービューからドラッグを開始したときの処理 >>> 
3307|************************************************************************/
3308|void  CMainFrame::OnTreeBeginDrag( CPoint point )
3309|{
3310|  CTreeCtrl*  tree = &m_Left->GetTreeCtrl();
3311|  RECT  rect;
3312|
3313|
3314|  /* ドラッグするアイテムを取得する */
3315|  m_DragItem = tree->HitTest( point, NULL );
3316|  tree->SelectItem( m_DragItem );
3317|  m_DragImageList = tree->CreateDragImage( m_DragItem );
3318|  ASSERT( m_DragImageList != 0 );
3319|
3320|
3321|  /* マウスをドラッグ中のものにする */
3322|  tree->GetItemRect( m_DragItem, &rect, TRUE );
3323|  m_DragImageList->BeginDrag( 0,
3324|    point + CPoint( 18, 0 ) - CPoint( rect.left, rect.top ) );
3325|  m_Left->ClientToScreen( &point );
3326|  m_DragImageList->DragEnter( NULL, point );
3327|  SetWindowLong( tree->m_hWnd, GWL_STYLE,
3328|    GetWindowLong( tree->m_hWnd, GWL_STYLE ) | TVS_NOTOOLTIPS );
3329|
3330|  m_Left->SetCapture();  /* ドラッグを開始したツリー以外にはドロップしない */
3331|}
3332|
3333| 
3334|/***********************************************************************
3335|  13-26. <<< [CMainFrame::OnTreeDragMove] ツリービューをドラッグしているときの処理 >>> 
3336|************************************************************************/
3337|void  CMainFrame::OnTreeDragMove( UINT nFlags, CPoint point )
3338|{
3339|  CTreeCtrl*  tree = &m_Left->GetTreeCtrl();
3340|  HTREEITEM  dropItem;
3341|  bool  bAfter;
3342|  bool  bChild;
3343|  bool  bChildTarget;
3344|
3345|
3346|  dropItem = GetDropTarget( nFlags, point, &bAfter, &bChild, &bChildTarget );
3347|
3348|
3349|  /* マウスを移動する */
3350|  m_Left->ClientToScreen( &point );
3351|  m_DragImageList->DragMove( point );
3352|
3353|
3354|  /* ドロップ先を表示する */
3355|  if ( dropItem == NULL || bChildTarget ||
3356|       ( ! bAfter && ! bChild && tree->GetPrevSiblingItem( dropItem ) == m_DragItem ) ||
3357|       ( bAfter && tree->GetNextSiblingItem( dropItem ) == m_DragItem ) ) {
3358|    m_DragImageList->DragShowNolock( FALSE );
3359|    tree->SelectDropTarget( NULL );
3360|    tree->SetInsertMark( NULL );
3361|    tree->UpdateWindow();
3362|    m_DragImageList->DragShowNolock( TRUE );
3363|  }
3364|  else {
3365|    m_DragImageList->DragShowNolock( FALSE );
3366|    if ( bChild ) {
3367|      tree->SelectDropTarget( dropItem );
3368|      tree->SetInsertMark( NULL );
3369|    }
3370|    else {
3371|      tree->SelectDropTarget( NULL );
3372|      tree->SetInsertMark( dropItem, bAfter );
3373|    }
3374|    tree->UpdateWindow();  /* これが無いとゴミが残る */
3375|    m_DragImageList->DragShowNolock( TRUE );
3376|  }
3377|}
3378|
3379|
3380|HTREEITEM  CMainFrame::GetDropTarget( UINT nFlags, CPoint point,
3381|   bool* bAfter, bool* bChild, bool* bChildTarget )
3382|{
3383|  CTreeCtrl*  tree = &m_Left->GetTreeCtrl();
3384|  HTREEITEM  dropItem;
3385|  RECT  rect;
3386|
3387|
3388|  /* ドロップ先のアイテムを取得する */
3389|  dropItem = tree->HitTest( point, NULL );
3390|  if ( dropItem == NULL ) {
3391|    m_Left->GetClientRect( &rect );
3392|    if ( point.x >= rect.left && point.x <= rect.right ) {
3393|      dropItem = tree->GetFirstVisibleItem();
3394|      *bAfter = ( point.y > rect.top + 14 );
3395|      if ( *bAfter ) {
3396|        int  n = tree->GetVisibleCount();
3397|        HTREEITEM  item;
3398|
3399|        while ( n > 0 ) {
3400|          item = tree->GetNextVisibleItem( dropItem );
3401|          if ( item == NULL )  break;
3402|          dropItem = item;
3403|          n--;
3404|        }
3405|      }
3406|    }
3407|    *bChild = false;
3408|  }
3409|  else {
3410|    tree->GetItemRect( dropItem, &rect, TRUE );
3411|    *bAfter = point.y > ( rect.top * 2 / 5 + rect.bottom * 3 / 5 );
3412|    *bChild = ! *bAfter && (point.y >  ( rect.top * 3 / 5 + rect.bottom * 2 / 5 ));
3413|  }
3414|
3415|
3416|  /* ドロップ先が同じか子項目であるか確かめる */
3417|  *bChildTarget = false;
3418|  if ( dropItem != NULL ) {
3419|    SVGCat_Page*  srcPage = (SVGCat_Page*) tree->GetItemData( m_DragItem );
3420|    SVGCat_Page*  dstPage = (SVGCat_Page*) tree->GetItemData( dropItem );
3421|    SVGCat_Page*  page;
3422|
3423|    for ( page = dstPage; page != NULL; page = page->parent ) {
3424|      if ( page == srcPage ) {
3425|        *bChildTarget = true;
3426|        break;
3427|      }
3428|    }
3429|  }
3430|
3431|  return  dropItem;
3432|}
3433|
3434| 
3435|/***********************************************************************
3436|  13-27. <<< [CMainFrame::OnTreeEndDrag] ツリービューにドロップしたときの処理 >>> 
3437|************************************************************************/
3438|void  CMainFrame::OnTreeEndDrag( UINT nFlags, CPoint point )
3439|{
3440|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
3441|  CTreeCtrl*  tree = &m_Left->GetTreeCtrl();
3442|  HTREEITEM  dropItem;
3443|  bool  bAfter;
3444|  bool  bChild;
3445|  bool  bChildTarget;
3446|
3447|
3448|  /* マウスをドラッグ中のものから戻す */
3449|  ReleaseCapture();
3450|
3451|  m_DragImageList->DragLeave( this );
3452|  m_DragImageList->EndDrag();
3453|  delete  m_DragImageList;
3454|
3455|
3456|  /* ドロップ先の表示を終了する */
3457|  tree->SelectDropTarget(NULL);
3458|  tree->SetInsertMark( NULL );
3459|  SetWindowLong( tree->m_hWnd, GWL_STYLE,
3460|    GetWindowLong( tree->m_hWnd, GWL_STYLE ) & ~TVS_NOTOOLTIPS );
3461|
3462|
3463|  /* ドロップ先のアイテムを取得する */
3464|  dropItem = GetDropTarget( nFlags, point, &bAfter, &bChild, &bChildTarget );
3465|
3466|  if ( dropItem == NULL )
3467|    return;
3468|  if ( bChildTarget ) {
3469|    if ( dropItem != m_DragItem ) {
3470|      MessageBox( app->m_bJapanese ? "そこは子項目なので移動できません" :
3471|        "Can not move to child node." );
3472|    }
3473|    return;
3474|  }
3475|
3476|  MovePage( m_DragItem, dropItem, bAfter, bChild, true );
3477|}
3478|
3479|
3480| 
3481|/***********************************************************************
3482|  13-28. <<< [CMainFrame::OnTreeLButtonUp] ツリービューで左ボタンを離したときの処理 >>> 
3483|************************************************************************/
3484|void  CMainFrame::OnTreeLButtonUp( UINT nFlags, CPoint point )
3485|{
3486|}
3487|
3488| 
3489|/***********************************************************************
3490|  13-29. <<< [CMainFrame::OnTreeRClick] ツリー項目を右クリックしたときの処理 >>> 
3491|************************************************************************/
3492|void CMainFrame::OnTreeRClick()
3493|{
3494|  CMenu  menu;
3495|  CPoint  pos, clientPos;
3496|  CTreeCtrl*  tree = &m_Left->GetTreeCtrl();
3497|  HTREEITEM  item;
3498|
3499|  GetCursorPos( &pos );
3500|  clientPos = pos;  m_Left->ScreenToClient( &clientPos );
3501|
3502|  item = tree->HitTest( clientPos, NULL );
3503|  if ( item == NULL )  return;
3504|
3505|  tree->Select( item, TVGN_CARET );
3506|
3507|  menu.LoadMenu( IDR_TreeRight );
3508|  menu.GetSubMenu(0)->TrackPopupMenu( TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RIGHTBUTTON,
3509|    pos.x, pos.y, this, NULL );
3510|}
3511|
3512| 
3513|/***********************************************************************
3514|  13-30. <<< [CMainFrame::OnEditPageTitle] ページのタイトルを編集する >>> 
3515|************************************************************************/
3516|void CMainFrame::OnEditPageTitle()
3517|{
3518|  EditTitle();
3519|}
3520|
3521|
3522|/***********************************************************************
3523|  13-31. <<< [CMainFrame::EditTitle] ページのタイトルを編集する >>>
3524|************************************************************************/
3525|void  CMainFrame::EditTitle()
3526|{
3527|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
3528|  CTreeCtrl*  tree;
3529|  SVGCat_Page*  page;
3530|  HTREEITEM  item;
3531|
3532|  tree = &m_Left->GetTreeCtrl();
3533|  item = tree->GetSelectedItem();
3534|
3535|
3536|  page = (SVGCat_Page*)tree->GetItemData( item );
3537|
3538| if ( 0 && m_wndView->m_InkOverlay != NULL ) {
3539|  CInputDlg   dlg;
3540|
3541|  dlg.m_SelStart = 0;  dlg.m_SelEnd = -1;
3542|  dlg.m_Msg = "このページのタイトル";  dlg.m_Text = page->title;
3543|  dlg.m_bPath = false;
3544|  dlg.m_PenInputPanel = m_wndView->m_PenInputPanel;
3545|  dlg.m_bSetAtCursor = true;
3546|  if ( dlg.DoModal() == IDOK ) {
3547|    app->m_UndoBuf->AllocNewStep_PageTitle(
3548|      SVGCat_File_getPageNum( &app->m_file, page ),
3549|      page->title, dlg.m_Text );
3550|    StrX_cpy( page->title, dlg.m_Text, sizeof(page->title) );
3551|    tree->SetItemText( item, page->title );
3552|  }
3553| }
3554| else {
3555|  CInputDlg1   dlg;
3556|
3557|  dlg.m_SelStart = 0;  dlg.m_SelEnd = -1;
3558|  dlg.m_Msg = "このページのタイトル";  dlg.m_Text = page->title;
3559|  dlg.m_bPath = false;
3560|  dlg.m_PenInputPanel = m_wndView->m_PenInputPanel;
3561|  dlg.m_bSetAtCursor = true;
3562|  if ( dlg.DoModal() == IDOK ) {
3563|    app->m_UndoBuf->AllocNewStep_PageTitle(
3564|      SVGCat_File_getPageNum( &app->m_file, page ),
3565|      page->title, dlg.m_Text );
3566|    StrX_cpy( page->title, dlg.m_Text, sizeof(page->title) );
3567|    tree->SetItemText( item, page->title );
3568|  }
3569| }
3570|}
3571| 
3572|/***********************************************************************
3573|  13-32. <<< [CMainFrame::SetRecentFileMenu] 最近開いたファイルのメニューを設定する >>> 
3574|************************************************************************/
3575|void  CMainFrame::SetRecentFileMenu()
3576|{
3577|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
3578|  CMenu*  menu;
3579|  CMenu*  menu2;
3580|  int  i, n;
3581|  char  menuStr[70];
3582|  enum { iMenu = 14, nMenu = 17 };
3583|  enum { mf_type = MF_BYPOSITION | MF_STRING };
3584|
3585|  if ( m_hWnd == NULL )  return;
3586|
3587|  /* これまでのメニューを消す */
3588|  menu = GetMenu();  if ( menu == NULL )  return;
3589|  menu2 = menu->GetSubMenu( 0 );
3590|  n = menu2->GetMenuItemCount();
3591|  for ( i = 0; i < n - nMenu; i++ )
3592|    menu2->RemoveMenu( iMenu, MF_BYPOSITION );
3593|
3594|  /* メニューを足す */
3595|  if ( app->m_nRecentPath >= 1 ) {
3596|    chgToMenuString( menuStr, sizeof(menuStr), app->m_RecentPath[0], 1 );
3597|    menu2->InsertMenu( iMenu, mf_type, ID_Recent1, menuStr );
3598|  }
3599|  if ( app->m_nRecentPath >= 2 ) {
3600|    chgToMenuString( menuStr, sizeof(menuStr), app->m_RecentPath[1], 2 );
3601|    menu2->InsertMenu( iMenu+1, mf_type, ID_Recent2, menuStr );
3602|  }
3603|  if ( app->m_nRecentPath >= 3 ) {
3604|    chgToMenuString( menuStr, sizeof(menuStr), app->m_RecentPath[2], 3 );
3605|    menu2->InsertMenu( iMenu+2, mf_type, ID_Recent3, menuStr );
3606|  }
3607|  if ( app->m_nRecentPath >= 4 ) {
3608|    chgToMenuString( menuStr, sizeof(menuStr), app->m_RecentPath[3], 4 );
3609|    menu2->InsertMenu( iMenu+3, mf_type, ID_Recent4, menuStr );
3610|  }
3611|  if ( app->m_nRecentPath >= 5 ) {
3612|    chgToMenuString( menuStr, sizeof(menuStr), app->m_RecentPath[4], 5 );
3613|    menu2->InsertMenu( iMenu+4, mf_type, ID_Recent5, menuStr );
3614|  }
3615|  if ( app->m_nRecentPath >= 6 ) {
3616|    chgToMenuString( menuStr, sizeof(menuStr), app->m_RecentPath[5], 6 );
3617|    menu2->InsertMenu( iMenu+5, mf_type, ID_Recent6, menuStr );
3618|  }
3619|  if ( app->m_nRecentPath >= 7 ) {
3620|    chgToMenuString( menuStr, sizeof(menuStr), app->m_RecentPath[6], 7 );
3621|    menu2->InsertMenu( iMenu+6, mf_type, ID_Recent7, menuStr );
3622|  }
3623|  if ( app->m_nRecentPath >= 8 ) {
3624|    chgToMenuString( menuStr, sizeof(menuStr), app->m_RecentPath[7], 8 );
3625|    menu2->InsertMenu( iMenu+7, mf_type, ID_Recent8, menuStr );
3626|  }
3627|}
3628|
3629|
3630| 
3631|/***********************************************************************
3632|  13-33. <<< [CMainFrame::OpenRecentFile] 最近開いたファイルを再び開く >>> 
3633|************************************************************************/
3634|void CMainFrame::OpenRecentFile( int i )
3635|{
3636|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
3637|  CString  s;
3638|  char  command[_MAX_PATH*2];
3639|
3640|  /* 最近開いたファイルが存在しないとき、履歴リストから削除するか確認する */
3641|  if ( ! FileX_isExist( app->m_RecentPath[i] ) ) {
3642|    if ( app->m_RecentPath[i][0] == '\\' && app->m_RecentPath[i][1] == '\\' ) {
3643|      if ( app->m_bJapanese )  s.LoadString( IDS_NotFound2 );
3644|      else  s.LoadString( IDS_NotFound2_E );
3645|      if ( MessageBox( CString(app->m_RecentPath[i]) + s, NULL,
3646|          MB_YESNO | MB_ICONWARNING ) == IDYES )
3647|        app->RemoveRecentFile( app->m_RecentPath[i] );
3648|      else
3649|        app->SetRecentFile( app->m_RecentPath[i] );
3650|    }
3651|    else {
3652|      if ( app->m_bJapanese )  s.LoadString( IDS_NotFound );
3653|      else  s.LoadString( IDS_NotFound_E );
3654|      MessageBox( CString(app->m_RecentPath[i]) + s, NULL,
3655|          MB_OK | MB_ICONWARNING );
3656|      app->SetRecentFile( app->m_RecentPath[i] );
3657|    }
3658|    SetRecentFileMenu();
3659|    app->WriteRecentFile();
3660|    return;
3661|  }
3662|
3663|  /* 新しいウィンドウで開く */
3664|  if ( app->m_bTaskTray && stricmp( app->m_RecentPath[i], app->m_path ) != 0 ) {
3665|    strcpy( command, StrX_argv0 );
3666|    strcat( command, " \"" );
3667|    strcat( command, app->m_RecentPath[i] );
3668|    strcat( command, "\"" );
3669|
3670|    WinExec( command, SW_SHOW );
3671|  }
3672|
3673|  /* 同じウィンドウで開く */
3674|  else {
3675|    RestoreWindow( false, NULL );
3676|    m_wndView->OnFinishPrimMove();
3677|    m_wndView->ResetSelect();
3678|
3679|    if ( m_wndView->IsDirty() ) {
3680|      int  r;
3681|
3682|      if ( app->m_bJapanese )  s.LoadString( IDS_SaveConfirm );
3683|      else  s.LoadString( IDS_SaveConfirm_E );
3684|      ::SetWindowPos( m_hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE );
3685|      r = MessageBox( s, app->m_path, MB_YESNOCANCEL | MB_ICONWARNING );
3686|
3687|      switch ( r ) {
3688|        case  IDYES:  OnSaveOv();  return;
3689|        case  IDCANCEL:  return;
3690|      }
3691|    }
3692|
3693|    Load( app->m_RecentPath[i], true );
3694|  }
3695|}
3696|
3697|void CMainFrame::OnRecent1()
3698|{
3699|  OpenRecentFile(0);
3700|}
3701|
3702|void CMainFrame::OnRecent2()
3703|{
3704|  OpenRecentFile(1);
3705|}
3706|
3707|void CMainFrame::OnRecent3()
3708|{
3709|  OpenRecentFile(2);
3710|}
3711|
3712|void CMainFrame::OnRecent4()
3713|{
3714|  OpenRecentFile(3);
3715|}
3716|
3717|void CMainFrame::OnRecent5()
3718|{
3719|  OpenRecentFile(4);
3720|}
3721|
3722|void CMainFrame::OnRecent6()
3723|{
3724|  OpenRecentFile(5);
3725|}
3726|
3727|void CMainFrame::OnRecent7()
3728|{
3729|  OpenRecentFile(6);
3730|}
3731|
3732|void CMainFrame::OnRecent8()
3733|{
3734|  OpenRecentFile(7);
3735|}
3736|
3737|
3738| 
3739|/***********************************************************************
3740|  13-34. <<< [CMainFrame::OnReload] 開きなおす >>> 
3741|************************************************************************/
3742|void CMainFrame::OnReload()
3743|{
3744|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
3745|  CString  s;
3746|
3747|  m_wndView->OnFinishPrimMove();
3748|  m_wndView->ResetSelect();
3749|
3750|  if ( ! FileX_isExist( app->m_path ) ) {
3751|    return;
3752|  }
3753|
3754|  if ( m_wndView->IsDirty() ) {
3755|    int  r;
3756|
3757|    if ( app->m_bJapanese )  s.LoadString( IDS_SaveConfirm );
3758|    else  s.LoadString( IDS_SaveConfirm_E );
3759|    ::SetWindowPos( m_hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE );
3760|    r = MessageBox( s, app->m_path, MB_YESNOCANCEL | MB_ICONWARNING );
3761|
3762|    switch ( r ) {
3763|      case  IDYES:  OnSaveOv();  break;
3764|      case  IDCANCEL:  return;
3765|    }
3766|  }
3767|
3768|  Load( app->m_path, ! app->m_bTaskTray );
3769|}
3770| 
3771|/***********************************************************************
3772|  13-35. <<< [CMainFrame::OnTaskTray] タスクトレイにアイコンを表示するを選んだときの処理 >>> 
3773|************************************************************************/
3774|void CMainFrame::OnTaskTray()
3775|{
3776|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
3777|
3778|  app->m_bTaskTray = ! app->m_bTaskTray;
3779|  if ( ! app->m_bTaskTray )
3780|    { app->m_bUpdsk = false;  app->m_bAutoSave = false; }
3781|
3782|  if ( app->m_bTaskTray )
3783|    AddToTaskTray();
3784|  else
3785|    RemoveFromTaskTray();
3786|}
3787|
3788|
3789|void CMainFrame::OnCloseTaskTray()
3790|{
3791|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
3792|
3793|  if ( app->m_bTaskTray )
3794|    OnTaskTray();
3795|}
3796|
3797|void CMainFrame::OnAutoSave()
3798|{
3799|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
3800|
3801|  app->m_bAutoSave = ! app->m_bAutoSave;
3802|}
3803|
3804|
3805|void CMainFrame::OnUpdsk()
3806|{
3807|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
3808|
3809|  app->m_bUpdsk = ! app->m_bUpdsk;
3810|}
3811|
3812|
3813| 
3814|/***********************************************************************
3815|  13-36. <<< [CMainFrame::OnEditCut] クリップボードに保存してカットする >>> 
3816|************************************************************************/
3817|void CMainFrame::OnEditCut()
3818|{
3819|  OnEditCopy();
3820|  m_ClipPageNum = -1;
3821|
3822|  m_wndView->OnDel();
3823|}
3824|
3825|
3826| 
3827|/***********************************************************************
3828|  13-37. <<< [CMainFrame::OnEditCopy] クリップボードに保存する >>> 
3829|【補足】
3830|・図形に関しては、CChildView::GetClipData で行っています。
3831|************************************************************************/
3832|int  cmpTextOrder( const void*, const void* );
3833|
3834|void CMainFrame::OnEditCopy()
3835|{
3836|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
3837|  HGLOBAL  data;
3838|  void*  block;
3839|  int    block_size;
3840|  bool   bPageCopy = ( m_wndSplitter.GetActivePane() == m_Left );
3841|
3842|  m_ClipPageNum = app->m_file.m_CurrentPageNum;
3843|
3844|
3845|  /* クリアする */
3846|  if ( OpenClipboard() ) {
3847|    EmptyClipboard();
3848|    CloseClipboard();
3849|  }
3850|  else {
3851|    MessageBox( "Can not open Clipboard" );
3852|    return;
3853|  }
3854|
3855|  /* インクをクリップボードへコピーする */
3856|  if ( ( m_wndView->GetSelectedStrokeCount() > 0 || bPageCopy ) &&
3857|         m_wndView->m_InkOverlay != NULL ) {
3858|    HRESULT  hr;
3859|    IInkDisp*  ink;
3860|    IDataObject*  obj;
3861|    IInkRectangle*  rc;
3862|    IInkStrokes*  strokes;
3863|    RECT  rc2;
3864|
3865|    hr = m_wndView->m_InkOverlay->get_Ink( &ink );
3866|    if ( hr != 0 )  error();
3867|
3868|    if ( bPageCopy ) {
3869|      hr = ink->get_Strokes( &strokes );
3870|      if ( hr != 0 )  error();
3871|
3872|      hr = ink->ClipboardCopy( strokes, ICF_Default, ICB_Default, &obj );
3873|      if ( hr != 0 )  error();
3874|      hr = strokes->GetBoundingBox( IBBM_Default, &rc );
3875|      if ( hr != 0 )  error();
3876|    }
3877|    else {
3878|      hr = ink->ClipboardCopy( m_wndView->m_HoldStrokes, ICF_Default, ICB_Default, &obj );
3879|      if ( hr != 0 )  error();
3880|      hr = m_wndView->m_HoldStrokes->GetBoundingBox( IBBM_Default, &rc );
3881|      if ( hr != 0 )  error();
3882|    }
3883|
3884|    hr = rc->get_Data( &rc2 );
3885|    if ( hr != 0 )  error();
3886|
3887|    rc->Release();  rc = NULL;
3888|    ink->Release();  ink = NULL;
3889|    if ( obj != NULL )  { obj->Release();  obj = NULL; }
3890|
3891|    if ( ! OpenClipboard() )  error();
3892|    data = GlobalAlloc( GMEM_DDESHARE, sizeof(RECT) );
3893|    block = GlobalLock( data );
3894|    memcpy( block, &rc2, sizeof(RECT) );
3895|    GlobalUnlock( data );
3896|    SetClipboardData( SVGCats_ClipFormat2, data );
3897|    CloseClipboard();
3898|  }
3899|
3900|
3901|  if ( OpenClipboard() ) {
3902|
3903|    /* 1ページしかコピーできないことを警告する */
3904|    SVGCat_Page*  page = SVGCat_File_getCurrentPage( &app->m_file );
3905|
3906|    if ( page->firstChild != NULL && m_wndSplitter.GetActivePane() == m_Left )
3907|      MessageBox( "子ページはクリップボードに格納されません。", "警告", MB_OK );
3908|
3909|
3910|    /* 図形をクリップボードへコピーする */
3911|    {
3912|      block_size = m_wndView->GetClipSize( bPageCopy );
3913|      if ( block_size % 4 != 0 )  error();
3914|      if ( block_size > 0 ) {
3915|
3916|        data = GlobalAlloc( GMEM_DDESHARE, block_size );
3917|        block = GlobalLock( data );
3918|        m_wndView->GetClipData( block, bPageCopy );
3919|        GlobalUnlock( data );
3920|
3921|        SetClipboardData( SVGCats_ClipFormat, data );
3922|      }
3923|    }
3924|
3925|
3926|    /* テキストをクリップボードへコピーする */
3927|    {
3928|      CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
3929|      ListX_ElemX*  p;
3930|      CadPrim*  prim;
3931|      CString  s;
3932|      Text_Box**  texts;
3933|      int  i, nText;
3934|
3935|      if ( bPageCopy ) {
3936|        texts = (Text_Box**)malloc( sizeof(Text_Box*) *
3937|          ListX_getN( &app->m_file.m_prims, ListX_ElemX ) );
3938|      }
3939|      else {
3940|        texts = (Text_Box**)malloc( sizeof(Text_Box*) *
3941|          ListX_getN( &m_wndView->m_MultiHolds, ListX_ElemX ) );
3942|      }
3943|
3944|      /* 選択中のテキストを Y 方向でソートする */
3945|      nText = 0;
3946|      if ( bPageCopy ) {
3947|        for ( ListX_forEach( &app->m_file.m_prims, &p, ListX_ElemX ) ) {
3948|          prim = (CadPrim*)p->p;
3949|          if ( prim->GetTypeID() == Text_Box_TypeID ) {
3950|            texts[nText] = (Text_Box*)prim;
3951|            nText++;
3952|          }
3953|        }
3954|      }
3955|      else {
3956|        for ( ListX_forEach ( &m_wndView->m_MultiSelects, &p, ListX_ElemX ) ) {
3957|          prim = (CadPrim*)p->p;
3958|          if ( prim->GetTypeID() == Text_Box_TypeID ) {
3959|            texts[nText] = (Text_Box*)prim;
3960|            nText++;
3961|          }
3962|        }
3963|      }
3964|      qsort( texts, nText, sizeof(Text_Box*), cmpTextOrder );
3965|
3966|
3967|      /* テキストを作成する */
3968|      s = "";
3969|      for ( i = 0; i < nText; i++ ) {
3970|        if ( i > 0 )  s += "\r\n";
3971|        s += texts[i]->m_Text;
3972|      }
3973|
3974|
3975|      /* テキストをクリップボードへ */
3976|      if ( nText > 0 ) {
3977|        data = GlobalAlloc( GMEM_DDESHARE, s.GetLength() + 1 );
3978|        block = GlobalLock( data );
3979|        strcpy( (char*)block, s );
3980|        GlobalUnlock( data );
3981|
3982|        SetClipboardData( CF_TEXT, data );
3983|      }
3984|      free( texts );
3985|    }
3986|
3987|    /* 画像をクリップボードへコピーする */
3988|    {
3989|      CadPrim*  prim = m_wndView->m_HoldPrim;
3990|
3991|      if ( prim != NULL && prim->GetTypeID() == Rect_Ex_TypeID &&
3992|           ((Rect_Ex*)prim)->m_ShapeType == Rect_ImageShape ) {
3993|
3994|        CBitmap   bmp;
3995|        CDC       bmp_dc;
3996|        CBitmap*  oldBmp;
3997|        CadPrim_DrawParam  pa;
3998|        Rect_Ex*  rect = (Rect_Ex*)prim;
3999|
4000|        bmp.CreateBitmap( rect->m_Rect.w, rect->m_Rect.h,
4001|          1, WinX_getDisplayBpp(), NULL );
4002|        bmp_dc.CreateCompatibleDC( NULL );
4003|        oldBmp = bmp_dc.SelectObject( &bmp );
4004|
4005|        /* 拡大率を 100% 、描画位置を 0,0 に */
4006|        m_wndView->GetDrawParam( &pa );
4007|        pa.x0 = rect->m_Rect.x;  pa.y0 = rect->m_Rect.y;
4008|        pa.zoom = 100;            pa.bDrawHandle = false;
4009|
4010|        rect->Draw( &bmp_dc, &pa );
4011|
4012|        bmp_dc.SelectObject( oldBmp );
4013|
4014|        SetClipboardData( CF_BITMAP, bmp );
4015|      }
4016|    }
4017|
4018|    CloseClipboard();
4019|  }
4020|  else  error();
4021|}
4022|
4023|
4024|int  cmpTextOrder( const void* a, const void* b )
4025|{
4026|  Text_Box*  aa = *(Text_Box**)a;
4027|  Text_Box*  bb = *(Text_Box**)b;
4028|
4029|  if ( aa->m_Y == bb->m_Y )  return  aa->m_CenterX - bb->m_CenterX;
4030|  else  return  aa->m_Y - bb->m_Y;
4031|}
4032|
4033|
4034| 
4035|/***********************************************************************
4036|  13-38. <<< [CMainFrame::OnDrawClipboard] クリップボードの内容が書き換えられたときの処理 >>> 
4037|************************************************************************/
4038|void CMainFrame::OnDrawClipboard()
4039|{
4040|	CFrameWnd::OnDrawClipboard();
4041|
4042|  ::SendMessage( m_NextClipChain, WM_DRAWCLIPBOARD, 0, 0 );
4043|
4044|	m_PasteCount = 0;
4045|}
4046|
4047| 
4048|/***********************************************************************
4049|  13-39. <<< [CMainFrame::OnChangeCbChain] >>> 
4050|************************************************************************/
4051|void CMainFrame::OnChangeCbChain(HWND hWndRemove, HWND hWndAfter)
4052|{
4053|	CFrameWnd::OnChangeCbChain(hWndRemove, hWndAfter);
4054|
4055|  if ( hWndRemove == m_NextClipChain )
4056|    m_NextClipChain = hWndAfter;
4057|}
4058|
4059| 
4060|/***********************************************************************
4061|  13-40. <<< [CMainFrame::OnEditPaste] クリップボードの内容を貼り付ける >>> 
4062|【補足】
4063|・図形に関しては、CChildView::Paste で行っています。
4064|************************************************************************/
4065|void CMainFrame::OnEditPaste()
4066|{
4067|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
4068|  HGLOBAL  data;
4069|  void*  p;
4070|  RECT  primsRect;
4071|  RECT  inkRect;
4072|  RECT  pasteRect;
4073|  bool  bDone = false;
4074|
4075|  OnSelect();
4076|  m_wndSplitter.SetActivePane( 0, 0, m_wndView );
4077|
4078|  inkRect.left = INT_MAX;   inkRect.top = INT_MAX;
4079|  inkRect.right = INT_MIN;  inkRect.bottom = INT_MIN;
4080|  primsRect.left = INT_MAX;   primsRect.top = INT_MAX;
4081|  primsRect.right = INT_MIN;  primsRect.bottom = INT_MIN;
4082|  pasteRect.left = INT_MAX;   pasteRect.top = INT_MAX;
4083|  pasteRect.right = INT_MIN;  pasteRect.bottom = INT_MIN;
4084|
4085|  app->m_UndoBuf->StartMulti();
4086|
4087|  if ( OpenClipboard() ) {
4088|
4089|    /* 図形を貼り付ける, ページを貼り付ける */
4090|    data = GetClipboardData( SVGCats_ClipFormat );
4091|    if ( data != NULL && ! bDone ) {
4092|      p = GlobalLock( data );
4093|      m_wndView->Paste( p, m_PasteCount + ( m_ClipPageNum == app->m_file.m_CurrentPageNum ),
4094|        &primsRect );
4095|      GlobalUnlock( data );
4096|
4097|      pasteRect.left = primsRect.left - 8;
4098|      pasteRect.top = primsRect.top - 8;
4099|      pasteRect.right = primsRect.right + 8;
4100|      pasteRect.bottom = primsRect.bottom + 8;
4101|
4102|      bDone = true;
4103|    }
4104|
4105|    /* テキストを貼り付ける */
4106|    data = GetClipboardData( CF_TEXT );
4107|    if ( data != NULL && ! bDone ) {
4108|      char*  sp;
4109|      char   s[4];
4110|      ListX_ElemX*  e;
4111|
4112|      for ( ListX_forEach( &m_wndView->m_MultiHolds, &e, ListX_ElemX ) )
4113|        ((CadPrim*)e->p)->SetHold( false );
4114|      ListX_toEmptyDelete( &m_wndView->m_MultiHolds, ListX_ElemX, NULL );
4115|
4116|      data = GetClipboardData( CF_TEXT );
4117|      if ( data != NULL ) {
4118|        p = GlobalLock( data );
4119|        sp = StrX_cpy1Line( s, sizeof(s), (char*)p, 2 );
4120|        if ( ( sp != NULL && sp[0] != '\0' ) ||
4121|             StrX_cpy1Line( s, sizeof(s), (char*)p, 3 ) != NULL ) {
4122|          int  r;
4123|          CString  s;
4124|
4125|          GlobalUnlock( data );
4126|          CloseClipboard();
4127|          if ( app->m_bJapanese )
4128|            s.LoadString( IDS_PasteMultilineText );
4129|          else
4130|            s.LoadString( IDS_PasteMultilineText_E );
4131|          r = MessageBox( s, "Paste", MB_YESNOCANCEL | MB_DEFBUTTON2 );
4132|
4133|          if ( r == IDYES ) {
4134|            if ( ! OpenClipboard() )  error();
4135|            data = GetClipboardData( CF_TEXT );  if ( data == NULL )  error();
4136|            p = GlobalLock( data );
4137|            m_wndView->PasteText( p, true, &primsRect );
4138|            GlobalUnlock( data );
4139|            goto  end_of_paste_text;
4140|          }
4141|          else if ( r == IDCANCEL )
4142|            goto  end_of_paste_text;
4143|        }
4144|        p = GlobalLock( data );
4145|        sp = (char*)malloc( strlen( (char*)p ) + 1 );
4146|        strcpy( sp, (char*)p );
4147|        while ( StrX_getLast( sp ) == '\r' || StrX_getLast( sp ) == '\n' ) {
4148|          StrX_cutLastOf2( sp, '\r' );
4149|          StrX_cutLastOf2( sp, '\n' );
4150|        }
4151|        if ( strchr( sp, '\n' ) == NULL )  StrX_trim( sp );
4152|        m_wndView->PasteText( sp, false, &primsRect );
4153|        free( sp );
4154|        GlobalUnlock( data );
4155|
4156|        pasteRect.left = primsRect.left - 8;
4157|        pasteRect.top = primsRect.top - 8;
4158|        pasteRect.right = primsRect.right + 8;
4159|        pasteRect.bottom = primsRect.bottom + 8;
4160|      }
4161| end_of_paste_text:
4162|      bDone = true;
4163|    }
4164|
4165|    /* ビットマップを貼り付ける */
4166|    data = GetClipboardData( CF_BITMAP );
4167|    if ( data != NULL && ! bDone ) {
4168|      BITMAP  b;
4169|      char*  buf;
4170|      char  imgWorkPath[_MAX_PATH];
4171|
4172|      GetObject( (HBITMAP)data, sizeof(BITMAP), (LPSTR)&b );
4173|
4174|      buf = (char*) malloc( b.bmWidthBytes * b.bmHeight );
4175|      GetBitmapBits( (HBITMAP)data, b.bmWidthBytes * b.bmHeight, buf );
4176|
4177|      /* PNGに変換する */
4178|      if ( m_bCaptureFormat == 1 ) {
4179|        strcpy( imgWorkPath, app->GetImgWorkFilePath( (long)m_hWnd ) );
4180|        StrX_chgExt( imgWorkPath, "png" );
4181|
4182|        CompressToPng( b.bmWidth, b.bmHeight, b.bmWidthBytes,
4183|          buf, b.bmBitsPixel, imgWorkPath );
4184|      }
4185|
4186|      /* JPEGに変換する */
4187|      else {
4188|        strcpy( imgWorkPath, app->GetImgWorkFilePath( (long)m_hWnd ) );
4189|        StrX_chgExt( imgWorkPath, "jpg" );
4190|
4191|        CompressPictureToJpeg( b.bmWidth, b.bmHeight, b.bmWidthBytes,
4192|          buf, false, b.bmBitsPixel, imgWorkPath );
4193|      }
4194|
4195|      free( buf );
4196|
4197|      /* 作成した JPEG ファイルを図形としてキャンバスに追加する */
4198|      {
4199|        Rect_Ex*  rect;
4200|        ListX_ElemX*  p;
4201|        POINT  pt;
4202|
4203|        OnSelect();
4204|        m_wndSplitter.SetActivePane( 0, 0, m_wndView );
4205|        m_wndView->ResetSelect();
4206|        pt = m_wndView->GetScrollPosition();
4207|
4208|        rect = new Rect_Ex;
4209|        rect->m_id = app->GetNewPrimID();
4210|        rect->m_bSelected = true;
4211|        Rect_init( &rect->m_Rect, pt.x, pt.y, 1, 1 );
4212|        rect->m_BorderWidth = 1;
4213|        rect->m_BorderColor = 0;
4214|        rect->m_FillColor = 0xFFFFFF;
4215|        rect->m_ShapeType = Rect_ImageShape;
4216|        rect->m_ImgPath = "";
4217|        rect->m_ImgWorkPath = imgWorkPath;
4218|        app->AddPrim( &app->m_file, rect );
4219|
4220|        m_wndView->m_HoldPrim = rect;
4221|        ListX_toEmptyDelete( &m_wndView->m_MultiHolds, ListX_ElemX, NULL );
4222|        p = ListX_addLastMalloc( &m_wndView->m_MultiHolds, ListX_ElemX );
4223|        p->p = m_wndView->m_HoldPrim;
4224|        rect->SetHold( true );
4225|        app->m_UndoBuf->AllocNewStep( NULL, rect->GetNewCopy( &app->m_file.m_prims ), NULL, NULL,
4226|          app->m_file.m_CurrentPageNum - app->m_file.m_StartPageNum );
4227|        m_wndView->SetMultiSelect();
4228|        //m_wndView->ResetScrollAndScale();
4229|        m_wndView->Redraw( false );
4230|        SetPropMulti( &m_wndView->m_MultiHolds, m_wndView->m_HoldStrokes );
4231|      }
4232|      bDone = true;
4233|    }
4234|
4235|    /* ファイルを貼り付ける */
4236|    data = GetClipboardData( CF_HDROP );
4237|    if ( data != NULL && ! bDone ) {
4238|//      char     path[_MAX_PATH];
4239|      HDROP  h;
4240|//      int  i, n;
4241|      POINT  point;
4242|
4243|      point.x = 20;  point.y = 20;
4244|
4245|      /* path に Shift-JIS 形式のパスを格納する */
4246|      h = (HDROP)GlobalLock( data );
4247|      DropFiles( h );
4248|
4249|#if 0
4250|      n = DragQueryFileW( h, -1, NULL, 0 );
4251|      for ( i = 0; i < n; i++ ) {
4252|        DragQueryFile( h, i, path, sizeof(char)*_MAX_PATH );
4253|        StrX_toLongPath( path, path );
4254|        DropFile( &point, path, i );
4255|      }
4256|      GlobalUnlock( data );
4257|#endif
4258|
4259|      bDone = true;
4260|    }
4261|    CloseClipboard();
4262|  }
4263|
4264|
4265|  /* インクを貼り付ける */
4266|  if ( m_wndView->m_InkOverlay != NULL ) {
4267|    HRESULT  hr;
4268|    IInkDisp*  ink;
4269|    VARIANT_BOOL  bCanPaste;
4270|    RECT  rc2;
4271|    static  long  dx, dy;
4272|    long  dx2, dy2;
4273|    IInkStrokes*  strokes;
4274|
4275|    hr = m_wndView->m_InkOverlay->get_Ink( &ink );
4276|    if ( hr != 0 )  error();
4277|
4278|    hr = ink->CanPaste( NULL, &bCanPaste );
4279|    if ( hr != 0 )  error();
4280|
4281|    if ( bCanPaste ) {
4282|
4283|      /* インクを貼り付ける位置を取得する */
4284|      if ( ! OpenClipboard() )  error();
4285|      data = GetClipboardData( SVGCats_ClipFormat2 );
4286|      if ( data == NULL ) {
4287|        rc2.left = 0;  rc2.top = 0;  rc2.right = 0;  rc2.bottom = 0;
4288|      }
4289|      else {
4290|        p = GlobalLock( data );
4291|        memcpy( &rc2, p, sizeof(RECT) );
4292|        GlobalUnlock( data );
4293|      }
4294|      CloseClipboard();
4295|
4296|
4297|      {
4298|        IInkRenderer*  render;
4299|        CClientDC  dc(this);
4300|        POINT  pt = m_wndView->GetScrollPosition();
4301|
4302|        /* インク座標(+8,+8)を計算する */
4303|        /* スクロール位置も考慮する */
4304|        hr = m_wndView->m_InkOverlay->get_Renderer( &render );
4305|        if ( hr != 0 )  error();
4306|
4307|        dx2 = 8 * ( m_PasteCount + ( m_ClipPageNum == app->m_file.m_CurrentPageNum ) );
4308|        dy2 = dx2;
4309|        dx2 -= pt.x;  dy2 -= pt.y;
4310|        hr = render->PixelToInkSpace( (long)dc.m_hDC, &dx2, &dy2 );
4311|        if ( hr != 0 )  error();
4312|
4313|        /* inkRect を計算する */
4314|        inkRect = rc2;
4315|        inkRect.left += dx2;  inkRect.top += dy2;
4316|        inkRect.right += dx2; inkRect.bottom += dy2;
4317|        hr = render->InkSpaceToPixel( (long)dc.m_hDC, &inkRect.left, &inkRect.top );
4318|        hr = render->InkSpaceToPixel( (long)dc.m_hDC, &inkRect.right, &inkRect.bottom );
4319|        inkRect.left += pt.x;  inkRect.top += pt.y;
4320|        inkRect.right += pt.x; inkRect.bottom += pt.y;
4321|
4322|        render->Release();  render = NULL;
4323|
4324|        if ( inkRect.left - 8 < pasteRect.left )      pasteRect.left = inkRect.left - 8;
4325|        if ( inkRect.top - 8 < pasteRect.top )        pasteRect.top = inkRect.top - 8;
4326|        if ( inkRect.right + 8 > pasteRect.right )    pasteRect.right = inkRect.right + 8;
4327|        if ( inkRect.bottom + 8 > pasteRect.bottom )  pasteRect.bottom = inkRect.bottom + 8;
4328|      }
4329|
4330|
4331|      /* インクを貼り付ける */
4332|      if ( m_wndView->m_HoldStrokes != NULL )
4333|        { hr = m_wndView->m_HoldStrokes->Release();  m_wndView->m_HoldStrokes = NULL; }
4334|
4335|      // OnRope();
4336|
4337|      hr = ink->ClipboardPaste( rc2.left + dx2, rc2.top + dy2, NULL, &strokes );
4338|      if ( hr != 0 )  error();
4339|
4340|      m_wndView->m_HoldStrokes = m_wndView->DuplicateStrokes( strokes );
4341|      m_wndView->SyncHoldStrokes();
4342|      m_wndView->Redraw( false );
4343|
4344|      app->m_UndoBuf->AllocNewStep_Ink2( Undo_Ink_Add, ink, m_wndView->m_HoldStrokes,
4345|        false, app->m_file.m_CurrentPageNum - app->m_file.m_StartPageNum );
4346|    }
4347|
4348|    ink->Release();  ink = NULL;
4349|  }
4350|
4351|  app->m_UndoBuf->EndMulti();
4352|
4353|  m_PasteCount++;
4354|
4355|
4356|  /* 貼り付けたい値がキャンバスの外なら、キャンバスを広げる */
4357|  if ( pasteRect.right > app->m_file.m_Canvas.m_Width ||
4358|       pasteRect.bottom > app->m_file.m_Canvas.m_Height ) {
4359|
4360|    if ( pasteRect.right > app->m_file.m_Canvas.m_Width )
4361|      app->m_file.m_Canvas.m_Width = pasteRect.right;
4362|
4363|    if ( pasteRect.bottom > app->m_file.m_Canvas.m_Height )
4364|      app->m_file.m_Canvas.m_Height = pasteRect.bottom;
4365|
4366|    m_wndView->SetScrollSize();
4367|    m_wndView->Invalidate( FALSE );
4368|  }
4369|
4370|
4371|  /* 貼り付けた位置へスクロールする */
4372|  {
4373|    POINT  pt = m_wndView->GetScrollPosition();
4374|    RECT  clientRc;
4375|    RECT  pasteRect2;
4376|
4377|    pasteRect2.left = pasteRect.left * m_wndView->m_Zoom / 100 - 8;
4378|    pasteRect2.top  = pasteRect.top * m_wndView->m_Zoom / 100 - 8;
4379|    pasteRect2.right= pasteRect.right * m_wndView->m_Zoom / 100 + 8;
4380|    pasteRect2.bottom=pasteRect.bottom * m_wndView->m_Zoom / 100 + 8;
4381|
4382|    m_wndView->GetClientRect( &clientRc );
4383|
4384|    if ( pasteRect2.right > pt.x + clientRc.right )  pt.x = pasteRect2.right - clientRc.right;
4385|    if ( pasteRect2.left < pt.x )  pt.x = pasteRect2.left;
4386|
4387|    if ( pasteRect2.bottom > pt.y + clientRc.bottom )  pt.y = pasteRect2.bottom - clientRc.bottom;
4388|    if ( pasteRect2.top < pt.y )  pt.y = pasteRect2.top;
4389|
4390|    m_wndView->ScrollToPosition( pt );
4391|  }
4392|
4393|  m_wndView->AnimateOnPaste();
4394|}
4395|
4396|
4397| 
4398|/***********************************************************************
4399|  13-41. <<< [CMainFrame::OnCopyStyle] スタイル(色や太さなど)をコピーする >>> 
4400|************************************************************************/
4401|void CMainFrame::OnCopyStyle()
4402|{
4403|  OnEditCopy();
4404|}
4405|
4406| 
4407|/***********************************************************************
4408|  13-42. <<< [CMainFrame::OnPasteStyle] スタイル(色や太さなど)を適用する >>> 
4409|************************************************************************/
4410|void CMainFrame::OnPasteStyle()
4411|{
4412|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
4413|  HGLOBAL  data;
4414|  void*  data_ptr;
4415|
4416|  app->m_UndoBuf->StartMulti();
4417|
4418|  /* 図形のスタイルの変更 */
4419|  if ( OpenClipboard() ) {
4420|
4421|    ListX_ElemX*  p;
4422|    int*   ip;
4423|    int    i;
4424|    int    n;
4425|    int    iBase;
4426|    CadPrim* src;
4427|    CadPrim* dst;
4428|    CadPrim* before;
4429|    Rect_Ex  rect;
4430|    Line_Ex  line;
4431|    Line_Corner  linec;
4432|    Text_Box  text;
4433|
4434|    data = GetClipboardData( SVGCats_ClipFormat );
4435|    if ( data != NULL ) {
4436|      data_ptr = GlobalLock( data );
4437|
4438|      ip = (int*)data_ptr;
4439|      n = *(ip + 2);
4440|      iBase = *(ip + 3);
4441|
4442|      if ( ! ( *(ip + 1) & 1 ) ) {  //ip = (int*)( (int)( strchr( (char*)(ip + 4), '\0' ) + 4 ) & ~3 );
4443|        ip += 4;
4444|        for ( i = 0; i < n; i++ ) {
4445|          switch ( *(ip + 1) ) {
4446|            case  Rect_Ex_TypeID:      src = &rect;  break;
4447|            case  Line_Ex_TypeID:      src = &line;  break;
4448|            case  Line_Corner_TypeID:  src = &linec;  break;
4449|            case  Text_Box_TypeID:     src = &text;  break;
4450|            default:  src= NULL;
4451|          }
4452|          if ( src != NULL ) {
4453|            src->CopyFromSerial( ip + 2 );
4454|            for ( ListX_forEach( &m_wndView->m_MultiSelects, &p, ListX_ElemX ) ) {
4455|              dst = (CadPrim*)p->p;
4456|              before = dst->GetNewCopy( &app->m_file.m_prims );
4457|
4458|              dst->copyStyle( src, &app->m_file.m_prims );
4459|
4460|              app->m_UndoBuf->AllocNewStep( before,
4461|                dst->GetNewCopy( &app->m_file.m_prims ), NULL, NULL,
4462|                app->m_file.m_CurrentPageNum - app->m_file.m_StartPageNum );
4463|            }
4464|          }
4465|          ip = (int*)( (char*)ip + *(ip + 0) );
4466|        }
4467|      }
4468|      GlobalUnlock( data_ptr );
4469|    }
4470|    CloseClipboard();
4471|  }
4472|
4473|
4474|  /* インクのスタイルの変更 */
4475|  {
4476|    HRESULT  hr;
4477|    IInkDisp*  ink;
4478|    VARIANT_BOOL  bCanInkPaste;
4479|    long  iStroke, nStroke;
4480|    IInkStrokeDisp*  stroke;
4481|    IInkStrokes*  pastedStrokes;
4482|    IInkStrokeDisp*  pastedStroke;
4483|    IInkDrawingAttributes*  attr;
4484|    Undo_InkAttr*  before;
4485|
4486|    hr = m_wndView->m_InkOverlay->get_Ink( &ink );  if ( hr != 0 )  error();
4487|    hr = ink->CanPaste( NULL, &bCanInkPaste );  if ( hr != 0 )  error();
4488|    if ( bCanInkPaste && m_wndView->m_HoldStrokes != NULL ) {
4489|
4490|      hr = m_wndView->m_HoldStrokes->get_Count( &nStroke );  if ( hr != 0 )  error();
4491|      before = Undo_InkAttr_new( m_wndView->m_HoldStrokes );
4492|
4493|      /* インクを見えない位置に貼り付ける */
4494|      hr = ink->ClipboardPaste( 0, 0, NULL, &pastedStrokes );  if ( hr != 0 )  error();
4495|
4496|
4497|      /* スタイルを変更する */
4498|      hr = pastedStrokes->Item( 0, &pastedStroke );  if ( hr != 0 )  error();
4499|      for ( iStroke = 0; iStroke < nStroke; iStroke++ ) {
4500|        hr = m_wndView->m_HoldStrokes->Item( iStroke, &stroke );  if ( hr != 0 )  error();
4501|        hr = pastedStroke->get_DrawingAttributes( &attr );  if ( hr != 0 )  error();
4502|        hr = stroke->putref_DrawingAttributes( attr );  if ( hr != 0 )  error();
4503|        hr = attr->Release();  attr = NULL;
4504|        hr = stroke->Release();  stroke = NULL;
4505|      }
4506|      hr = pastedStroke->Release();  pastedStroke = NULL;
4507|
4508|      hr = ink->DeleteStrokes( pastedStrokes );  if ( hr != 0 )  error();
4509|
4510|      app->m_UndoBuf->AllocNewStep_Ink3( Undo_Ink_ChgAttr, m_wndView->m_HoldStrokes,
4511|        before, Undo_InkAttr_new( m_wndView->m_HoldStrokes ),  app->m_file.m_CurrentPageNum - app->m_file.m_StartPageNum );
4512|    }
4513|
4514|    ink->Release();  ink = NULL;
4515|  }
4516|
4517|  app->m_UndoBuf->EndMulti();
4518|  m_wndView->Redraw( false );
4519|}
4520|
4521| 
4522|/***********************************************************************
4523|  13-43. <<< [CMainFrame::OnFind] 検索する >>> 
4524|************************************************************************/
4525|void CMainFrame::OnFind()
4526|{
4527|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
4528| if ( 0 && m_wndView->m_InkOverlay != NULL ) {
4529|  CInputDlg  dlg;
4530|
4531|  dlg.m_SelStart = 0;  dlg.m_SelEnd = -1;
4532|  dlg.m_Msg = app->m_bJapanese ? "検索する文字列" : "Keyword";
4533|  dlg.m_Text = m_KWord;
4534|  dlg.m_bPath = false;
4535|  dlg.m_PenInputPanel = m_wndView->m_PenInputPanel;
4536|// dlg.m_bDispPenPanel = m_wndView->m_bInputML_bDispPenPanel;
4537|  dlg.m_bSetAtCursor = true;
4538|  if ( dlg.DoModal() == IDOK ) {
4539|    if ( m_KWord != dlg.m_Text ) {
4540|      m_KWord = dlg.m_Text;
4541|      m_FoundPrim = NULL;
4542|      m_iFoundPage = -1;
4543|    }
4544|    OnFindNext();
4545|  }
4546|// m_wndView->m_bInputML_bDispPenPanel = dlg.m_bDispPenPanel;
4547| }
4548| else {
4549|  CInputDlg1  dlg;
4550|
4551|  dlg.m_SelStart = 0;  dlg.m_SelEnd = -1;
4552|  dlg.m_Msg = app->m_bJapanese ? "検索する文字列" : "Keyword";
4553|  dlg.m_Text = m_KWord;
4554|  dlg.m_bPath = false;
4555|  dlg.m_PenInputPanel = m_wndView->m_PenInputPanel;
4556|// dlg.m_bDispPenPanel = m_wndView->m_bInputML_bDispPenPanel;
4557|  dlg.m_bSetAtCursor = true;
4558|  if ( dlg.DoModal() == IDOK ) {
4559|    if ( m_KWord != dlg.m_Text ) {
4560|      m_KWord = dlg.m_Text;
4561|      m_FoundPrim = NULL;
4562|      m_iFoundPage = -1;
4563|    }
4564|    OnFindNext();
4565|  }
4566|// m_wndView->m_bInputML_bDispPenPanel = dlg.m_bDispPenPanel;
4567| }
4568|}
4569|
4570|
4571|void CMainFrame::OnFindNext()
4572|{
4573|  OnFind_sub( 1 );
4574|}
4575|
4576|void CMainFrame::OnFindBack()
4577|{
4578|  OnFind_sub( -1 );
4579|}
4580|
4581|void CMainFrame::OnFind_sub( int dir )
4582|{
4583|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
4584|  int  iPage;
4585|  ListX_ElemX*  p;
4586|
4587|  app->ChgPage( &app->m_file, app->m_file.m_CurrentPageNum );
4588|
4589|  m_wndView->ResetSelect();
4590|  if ( dir > 0 )
4591|    iPage = app->SearchByText( &app->m_file, m_KWord, &m_FoundPrim );
4592|  else
4593|    iPage = app->SearchReverseByText( &app->m_file, m_KWord, &m_FoundPrim );
4594|
4595|  if ( iPage == -1 ) {
4596|    MessageBox( CString(m_KWord) + ( app->m_bJapanese ?
4597|      " は見つかりませんでした。" : " not found." ), "", MB_OK );
4598|    ResetProp();
4599|  }
4600|  else {
4601|    ChgPage( iPage );
4602|
4603|    p = ListX_addLastMalloc( &m_wndView->m_MultiHolds, ListX_ElemX );
4604|    p->p = m_FoundPrim;
4605|    m_wndView->m_HoldPrim = m_FoundPrim;
4606|    m_FoundPrim->SetHold( true );
4607|
4608|    SetPropMulti( &m_wndView->m_MultiHolds, m_wndView->m_HoldStrokes );
4609|    m_iFoundPage = iPage;
4610|
4611|
4612|    /* 見つけた位置へスクロールする */
4613|    {
4614|      POINT  pt = m_wndView->GetScrollPosition();
4615|      RECT  clientRc;
4616|      RECT  pasteRect;
4617|      CadPrim_DrawParam  pa;
4618|
4619|      m_wndView->GetDrawParam( &pa );
4620|      m_FoundPrim->Draw( &m_wndView->m_MinBitmapDC, &pa );  /* Text_Box の範囲を決定するため */
4621|      pasteRect.left = m_FoundPrim->GetForAlign( CadPrim_AlignLeft );
4622|      pasteRect.right = m_FoundPrim->GetForAlign( CadPrim_AlignRight );
4623|      pasteRect.top = m_FoundPrim->GetForAlign( CadPrim_AlignTop );
4624|      pasteRect.bottom = m_FoundPrim->GetForAlign( CadPrim_AlignBottom );
4625|
4626|      m_wndView->GetClientRect( &clientRc );
4627|
4628|      if ( pasteRect.right + 8 > pt.x + clientRc.right )  pt.x = pasteRect.right + 8 - clientRc.right;
4629|      if ( pasteRect.left - 8 < pt.x )  pt.x = pasteRect.left - 8;
4630|
4631|      if ( pasteRect.bottom + 8 > pt.y + clientRc.bottom )  pt.y = pasteRect.bottom + 8 - clientRc.bottom;
4632|      if ( pasteRect.top - 8 < pt.y )  pt.y = pasteRect.top - 8;
4633|
4634|      m_wndView->ScrollToPosition( pt );
4635|    }
4636|  }
4637|  m_wndView->Invalidate( FALSE );
4638|  UpdateWindowText();
4639|}
4640|
4641|
4642| 
4643|/***********************************************************************
4644|  13-44. <<< [CMainFrame::ChgPage] 表示しているページを変更する >>> 
4645|【補足】
4646|・本関数を呼び出すと、CMainFrame::OnTreeSelchanged も呼ばれます。
4647|************************************************************************/
4648|void  CMainFrame::ChgPage( int iPage )
4649|{
4650|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
4651|  CTreeCtrl*  tree = &m_Left->GetTreeCtrl();
4652|  HTREEITEM  item, item2;
4653|  SVGCat_Page*  page;
4654|  int  iNowPage;
4655|
4656|  if ( iPage == 0 && app->m_file.m_StartPageNum == 0 ) {
4657|    OnMakeBackPage();
4658|    return;
4659|  }
4660|
4661|  item = tree->GetSelectedItem();
4662|  if ( item == NULL ) {
4663|    item = tree->GetFirstVisibleItem();
4664|    page = ListX_getFirst( &app->m_file.m_pages, SVGCat_Page );
4665|    if ( app->m_file.m_StartPageNum == 0 )
4666|      page = ListX_Elem_getNextT( page, SVGCat_Page );
4667|    iNowPage = 1;
4668|  }
4669|  else {
4670|    page = (SVGCat_Page*)tree->GetItemData( item );
4671|    iNowPage = ListX_getI( &app->m_file.m_pages, page ) + app->m_file.m_StartPageNum;
4672|  }
4673|
4674|  for (;;) {
4675|    while ( iPage > iNowPage ) {
4676|      item2 = tree->GetNextVisibleItem( item );
4677|      if ( item2 == NULL )  break;
4678|      item = item2;
4679|      page = (SVGCat_Page*)tree->GetItemData( item );
4680|      iNowPage = ListX_getI( &app->m_file.m_pages, page ) + app->m_file.m_StartPageNum;
4681|    }
4682|    while ( iPage < iNowPage ) {
4683|      item = tree->GetPrevVisibleItem( item );
4684|      page = (SVGCat_Page*)tree->GetItemData( item );
4685|      iNowPage = ListX_getI( &app->m_file.m_pages, page ) + app->m_file.m_StartPageNum;
4686|    }
4687|    if ( iPage > iNowPage ) {
4688|      tree->Expand( item, TVE_EXPAND );
4689|      item = tree->GetChildItem( item );
4690|      page = (SVGCat_Page*)tree->GetItemData( item );
4691|      iNowPage = ListX_getI( &app->m_file.m_pages, page ) + app->m_file.m_StartPageNum;
4692|      continue;
4693|    }
4694|    break;
4695|  }
4696|  tree->SelectItem( item );
4697|  tree->EnsureVisible( item );
4698|}
4699|
4700| 
4701|/***********************************************************************
4702|  13-45. <<< [CMainFrame::ChgPageByPrims] 表示しているページを変更する >>> 
4703|【補足】
4704|・本関数を呼び出すと、CMainFrame::OnTreeSelchanged も呼ばれます。
4705|************************************************************************/
4706|void  CMainFrame::ChgPageByPrims( SVGCat_File* file, ListX* targetPrims )
4707|{
4708|  SVGCat_Page*  page;
4709|
4710|  for ( ListX_forEach( &file->m_pages, &page, SVGCat_Page ) ) {
4711|    if ( &page->prims == targetPrims )  break;
4712|  }
4713|
4714|  ChgPage( ListX_getI( &file->m_pages, page ) + file->m_StartPageNum );
4715|}
4716|
4717| 
4718|/***********************************************************************
4719|  13-46. <<< [CMainFrame::MovePage] ページを移動する >>> 
4720|【引数】
4721|  ・bool  bAfter;  dstItem の後に移動するかどうか
4722|  ・bool  bChild;  dstItem の子の先頭に移動するかどうか
4723|  ・bool  bAddToUndoBuf;  移動をアンドゥバッファに入れるかどうか
4724|【補足】
4725|・bAfter = false, bChild = false なら、dstItem の前に移動します。
4726|・bAfter = true, bChild = true は指定できません。
4727|************************************************************************/
4728|void  CMainFrame::MovePage( HTREEITEM srcItem, HTREEITEM dstItem,
4729|  bool bAfter, bool bChild, bool bAddToUndoBuf )
4730|{
4731|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
4732|  CTreeCtrl*  tree = &m_Left->GetTreeCtrl();
4733|  SVGCat_Page*  page;
4734|  SVGCat_Page*  srcPage;
4735|  SVGCat_Page*  srcOverPage;
4736|  SVGCat_Page*  dstPage;
4737|  SVGCat_Page*  dstOverPage;
4738|  SVGCat_Page*  prevPage;
4739|  SVGCat_Page*  nextPage;
4740|  SVGCat_Page*  parentPage;
4741|  int  srcStartNum, srcOverNum, dstNum, redoBaseNum;
4742|  bool  bLast, bLonelyChild;
4743|
4744|  app->ChgPage( &app->m_file, -1 );
4745|
4746|
4747|  srcPage = (SVGCat_Page*) tree->GetItemData( srcItem );
4748|  bLast = ( srcPage->next == NULL );
4749|  bLonelyChild = bLast && (srcPage->prev == NULL);
4750|
4751|
4752|  /* 移動するページをツリーから外す */
4753|  dstPage = (SVGCat_Page*) tree->GetItemData( dstItem );
4754|  redoBaseNum = SVGCat_File_getPageNum( &app->m_file, dstPage );
4755|  srcOverPage = SVGCat_Page_getChildOver( srcPage );
4756|  dstOverPage = SVGCat_Page_getChildOver( dstPage );
4757|  prevPage = srcPage->prev;
4758|  nextPage = srcPage->next;
4759|  parentPage = srcPage->parent;
4760|  if ( prevPage != NULL )  prevPage->next = nextPage;
4761|  if ( nextPage != NULL )  nextPage->prev = prevPage;
4762|  if ( parentPage != NULL && parentPage->firstChild == srcPage )
4763|    parentPage->firstChild = nextPage;
4764|  srcPage->next = NULL;
4765|  srcPage->prev = NULL;
4766|  srcPage->parent = NULL;
4767|  tree->DeleteItem( srcItem );
4768|
4769|
4770|  /* 移動するページをツリーに戻す */
4771|  if ( bAfter ) {  /* dstPage の下に */
4772|    SVGCat_Page*  nextPage2;
4773|
4774|    nextPage2 = dstPage->next;
4775|    dstPage->next = srcPage;
4776|    if ( nextPage2 != NULL )  nextPage2->prev = srcPage;
4777|    srcPage->prev = dstPage;
4778|    srcPage->next = nextPage2;
4779|    srcPage->parent = dstPage->parent;
4780|
4781|    srcStartNum = ListX_getI( &app->m_file.m_pages, srcPage ) + app->m_file.m_StartPageNum;
4782|    srcOverNum = ListX_getI( &app->m_file.m_pages, srcOverPage ) + app->m_file.m_StartPageNum;
4783|    dstNum = ListX_getI( &app->m_file.m_pages, dstOverPage ) + app->m_file.m_StartPageNum;
4784|
4785|    app->MoveInkWorkFile( &app->m_file, srcStartNum, srcOverNum, dstNum );
4786|    ListX_moveSet( &app->m_file.m_pages, srcPage, srcOverPage, dstOverPage );
4787|
4788|    page = srcPage->next;  srcPage->next = NULL;
4789|    srcItem = LoadTree( tree, srcPage, tree->GetParentItem( dstItem ), dstItem );
4790|    srcPage->next = page;
4791|    tree->SetItemData( srcItem, (DWORD)srcPage );
4792|    tree->SelectItem( srcItem );
4793|  }
4794|  else if ( bChild ) {  /* dstPage の子に */
4795|    SVGCat_Page*  childPage2;
4796|
4797|    childPage2 = dstPage->firstChild;
4798|    dstPage->firstChild = srcPage;
4799|    srcPage->parent = dstPage;
4800|    srcPage->next = childPage2;
4801|    if ( childPage2 != NULL )  childPage2->prev = srcPage;
4802|
4803|    srcStartNum = ListX_getI( &app->m_file.m_pages, srcPage ) + app->m_file.m_StartPageNum;
4804|    srcOverNum = ListX_getI( &app->m_file.m_pages, srcOverPage ) + app->m_file.m_StartPageNum;
4805|    dstNum = ListX_getI( &app->m_file.m_pages, dstPage ) + 1 + app->m_file.m_StartPageNum;
4806|
4807|    app->MoveInkWorkFile( &app->m_file, srcStartNum, srcOverNum, dstNum );
4808|    ListX_moveSet( &app->m_file.m_pages, srcPage, srcOverPage,
4809|      ListX_Elem_getNextT( dstPage, SVGCat_Page ) );
4810|
4811|    page = srcPage->next;  srcPage->next = NULL;
4812|    srcItem = LoadTree( tree, srcPage, dstItem, TVI_FIRST );
4813|    srcPage->next = page;
4814|    tree->SetItemData( srcItem, (DWORD)srcPage );
4815|    tree->SelectItem( srcItem );
4816|  }
4817|  else { /* dstPage の上に */
4818|    SVGCat_Page*  prevPage2;
4819|    HTREEITEM  insAfter;
4820|
4821|    prevPage2 = dstPage->prev;
4822|    dstPage->prev = srcPage;
4823|    if ( prevPage2 != NULL )  prevPage2->next = srcPage;
4824|    srcPage->prev = prevPage2;
4825|    srcPage->next = dstPage;
4826|    srcPage->parent = dstPage->parent;
4827|
4828|    srcStartNum = ListX_getI( &app->m_file.m_pages, srcPage ) + app->m_file.m_StartPageNum;
4829|    srcOverNum = ListX_getI( &app->m_file.m_pages, srcOverPage ) + app->m_file.m_StartPageNum;
4830|    dstNum = ListX_getI( &app->m_file.m_pages, dstPage ) + app->m_file.m_StartPageNum;
4831|
4832|    app->MoveInkWorkFile( &app->m_file, srcStartNum, srcOverNum, dstNum );
4833|    ListX_moveSet( &app->m_file.m_pages, srcPage, srcOverPage, dstPage );
4834|
4835|    insAfter = tree->GetPrevSiblingItem( dstItem );
4836|    page = srcPage->next;  srcPage->next = NULL;
4837|    srcItem = LoadTree( tree, srcPage, tree->GetParentItem( dstItem ), insAfter );
4838|    srcPage->next = page;
4839|    tree->SetItemData( srcItem, (DWORD)srcPage );
4840|    tree->SelectItem( srcItem );
4841|  }
4842|
4843|  app->ChgPage( &app->m_file,
4844|    ListX_getI( &app->m_file.m_pages, srcPage ) + app->m_file.m_StartPageNum );
4845|
4846|  UpdateWindowText();
4847|
4848|
4849|  /* アンドゥバッファに記録する */
4850|  if ( bAddToUndoBuf ) {
4851|    int  beforeType;
4852|
4853|    /* beforeType を設定する */
4854|    if ( bLonelyChild )  beforeType = 2;
4855|    else if ( bLast )  beforeType = 1;
4856|    else  beforeType = 0;
4857|
4858|    /* redoBaseNum を設定する */
4859|    if ( bChild )  redoBaseNum = - redoBaseNum;
4860|    else if ( bAfter &&  srcPage->next == NULL )  /* redoBaseNum = redoBaseNum */;
4861|    else  redoBaseNum = 0;
4862|
4863|    /* ページ番号を調整する */
4864|    if ( dstNum < 1 )  dstNum = SVGCat_File_getMaxPageNum( &app->m_file ) + 1;
4865|    if ( srcOverNum < 1 )  srcOverNum = SVGCat_File_getMaxPageNum( &app->m_file ) + 1;
4866|    if ( bLast && ! bLonelyChild )  srcOverNum = SVGCat_File_getPageNum( &app->m_file, prevPage );
4867|
4868|    app->m_UndoBuf->AllocNewStep_Page( srcStartNum, srcOverNum, beforeType,
4869|      dstNum, redoBaseNum, NULL );
4870|  }
4871|}
4872|
4873|
4874| 
4875|/***********************************************************************
4876|  13-47. <<< [CMainFrame::OnEditTimeStamp] 日付時刻名前の形式を編集する >>> 
4877|【補足】
4878|・書式は、スタイル・セットで指定する。
4879|************************************************************************/
4880|#if 0
4881|void CMainFrame::OnEditTimeStamp()
4882|{
4883|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
4884|  CInputDlg  dlg;
4885|
4886|  dlg.m_SelStart = 0;  dlg.m_SelEnd = -1;
4887|  dlg.m_Msg = app->m_bJapanese ? "日付の形式(例:%y.%m.%d %H.%M.%S OK!)" :
4888|    "Time Stamp Format(ex:%y.%m.%d %H.%M.%S OK!)";
4889|  dlg.m_Text = app->m_TimeStampFormat;
4890|  dlg.m_bPath = false;
4891|  dlg.m_PenInputPanel = m_wndView->m_PenInputPanel;
4892|//  dlg.m_bDispPenPanel = m_wndView->m_bInputML_bDispPenPanel;
4893|  dlg.m_bSetAtCursor = true;
4894|  if ( dlg.DoModal() == IDOK ) {
4895|    StrX_cpy( app->m_TimeStampFormat, dlg.m_Text, sizeof(app->m_TimeStampFormat) );
4896|  }
4897|//  m_wndView->m_bInputML_bDispPenPanel = dlg.m_bDispPenPanel;
4898|}
4899|#endif
4900|
4901|
4902|/***********************************************************************
4903|  13-48. <<< [CMainFrame::OnPasteTimeStamp] 日付時刻名前の形式を貼り付ける >>>
4904|************************************************************************/
4905|void CMainFrame::OnPasteTimeStamp()
4906|{
4907|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
4908|
4909|  MessageBox( app->m_bJapanese ? "日付を貼り付ける位置でクリックしてください" :
4910|    "Click the place on setting the time stamp." );
4911|
4912|  OnCreateTimeStamp();
4913|}
4914| 
4915|/***********************************************************************
4916|  13-49. <<< [CMainFrame::OnReadCustomDesign] カスタムデザインセットをロードする  >>> 
4917|************************************************************************/
4918|void CMainFrame::OnReadCustomDesign()
4919|{
4920|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
4921|  char   path[_MAX_PATH];
4922|  CFileDialog  dlg( TRUE, "svg", NULL, OFN_HIDEREADONLY,
4923|                    app->m_bJapanese ? _svg_read_filter : _svg_read_filterE );
4924|  CString  s;
4925|
4926|  #ifdef  NDEBUG
4927|    dlg.m_ofn.Flags &= ~OFN_ENABLEHOOK;  /* Win2000以降の新しいファイルダイアログにする */
4928|  #endif
4929|  StrX_getExeFullPath( path, _design_path, sizeof(path) );
4930|  dlg.m_ofn.lpstrInitialDir = path;
4931|
4932|  if ( dlg.DoModal() == IDOK ) {
4933|    app->LoadDefaultDesign( dlg.GetPathName() );
4934|  }
4935|}
4936|
4937|
4938|/***********************************************************************
4939|  13-50. <<< [CMainFrame::OnReadDefDesign] デフォルトデザインセットをロードする >>>
4940|************************************************************************/
4941|void CMainFrame::OnReadDefDesign()
4942|{
4943|  ReadDefDesign( true );
4944|}
4945|
4946|void CMainFrame::ReadDefDesign( bool bWarning )
4947|{
4948|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
4949|  char   path[_MAX_PATH];
4950|
4951|  StrX_getExeFullPath( path, _design_path "\\Default Design.svg", sizeof(path) );
4952|  if ( ! FileX_isExist( path ) ) {
4953|    StrX_getExeFullPath( path, _design_path "\\Default Design.svgz", sizeof(path) );
4954|    if ( ! FileX_isExist( path ) ) {
4955|      if ( bWarning ) {
4956|        CString  s;
4957|
4958|        if ( app->m_bJapanese )  s.LoadString( IDS_NotFound );
4959|        else  s.LoadString( IDS_NotFound_E );
4960|        MessageBox( CString(path) + s, NULL, MB_OK );
4961|      }
4962|      return;
4963|    }
4964|  }
4965|
4966|  app->LoadDefaultDesign( path );
4967|}
4968|
4969|
4970|
4971|/***********************************************************************
4972|  13-51. <<< [CMainFrame::OnResetDesign] デザインセットをリセットする  >>>
4973|************************************************************************/
4974|void CMainFrame::OnResetDesign()
4975|{
4976|  if ( m_TextDesign != NULL )  { delete  m_TextDesign;  m_TextDesign = NULL; }
4977|  if ( m_TextRectDesign != NULL )  { delete  m_TextRectDesign;  m_TextRectDesign = NULL; }
4978|  if ( m_TextCircleDesign != NULL )  { delete  m_TextCircleDesign;  m_TextCircleDesign = NULL; }
4979|  if ( m_TextRoundRectDesign != NULL )  { delete  m_TextRoundRectDesign;  m_TextRoundRectDesign = NULL; }
4980|  if ( m_TextDiamondDesign != NULL )  { delete  m_TextDiamondDesign;  m_TextDiamondDesign = NULL; }
4981|  if ( m_TextParallelDesign != NULL )  { delete  m_TextParallelDesign;  m_TextParallelDesign = NULL; }
4982|  if ( m_LineDesign != NULL )  { delete  m_LineDesign;  m_LineDesign = NULL; }
4983|  if ( m_ArrowDesign != NULL )  { delete  m_ArrowDesign;  m_ArrowDesign = NULL; }
4984|  if ( m_CorneredLineDesign != NULL )  { delete  m_CorneredLineDesign;  m_CorneredLineDesign = NULL; }
4985|  if ( m_GuideLineTextDesign != NULL )  { delete  m_GuideLineTextDesign;  m_GuideLineTextDesign = NULL; }
4986|  if ( m_GuideLineArrowDesign != NULL )  { delete  m_GuideLineArrowDesign;  m_GuideLineArrowDesign = NULL; }
4987|  if ( m_RectDesign != NULL )  { delete  m_RectDesign;  m_RectDesign = NULL; }
4988|  if ( m_CircleDesign != NULL )  { delete  m_CircleDesign;  m_CircleDesign = NULL; }
4989|  if ( m_RoundRectDesign != NULL )  { delete  m_RoundRectDesign;  m_RoundRectDesign = NULL; }
4990|  if ( m_DiamondDesign != NULL )  { delete  m_DiamondDesign;  m_DiamondDesign = NULL; }
4991|  if ( m_RedTextDesign != NULL )  { delete  m_RedTextDesign;  m_RedTextDesign = NULL; }
4992|  if ( m_BlueTextDesign != NULL )  { delete  m_BlueTextDesign;  m_BlueTextDesign = NULL; }
4993|  if ( m_TimeStampDesign != NULL )  { delete  m_TimeStampDesign;  m_TimeStampDesign = NULL; }
4994|  if ( m_StrongerDesign != NULL )  { delete  m_StrongerDesign;  m_StrongerDesign = NULL; }
4995|}
4996|
4997|
4998|/***********************************************************************
4999|  13-52. <<< [CMainFrame::OnOpenDesign] デザインセットを編集する >>>
5000|************************************************************************/
5001|void CMainFrame::OnOpenDesign()
5002|{
5003|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
5004|  char   path[_MAX_PATH];
5005|
5006|  m_wndView->OnFinishPrimMove();
5007|  m_wndView->ResetSelect();
5008|
5009|  StrX_getExeFullPath( path, _design_path, sizeof(path) );
5010|
5011|  OnOpen_sub( path, false, false );
5012|}
5013|
5014|
5015| 
5016|/***********************************************************************
5017|  13-53. <<< [CMainFrame::OnSingleClick] プロパティなどをシングルクリックで編集できるモードにする >>> 
5018|************************************************************************/
5019|void CMainFrame::OnSingleClick()
5020|{
5021|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
5022|
5023|  app->m_bSingleClick = ! app->m_bSingleClick;
5024|  app->SaveSVGCatsIni();
5025|}
5026|
5027|
5028| 
5029|/***********************************************************************
5030|  13-54. <<< [CMainFrame::OnAlignHorizontal] 水平にそろえるを選んだときの処理 >>> 
5031|************************************************************************/
5032|void CMainFrame::OnAlignHorizontal()
5033|{
5034|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
5035|
5036|  app->Align( CadPrim_AlignHorizontal, &m_wndView->m_MultiHolds,
5037|    m_wndView->m_HoldPrim );
5038|  m_wndView->Redraw( false );
5039|}
5040|
5041|void CMainFrame::OnAlignVertical()
5042|{
5043|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
5044|
5045|  app->Align( CadPrim_AlignVertical, &m_wndView->m_MultiHolds,
5046|    m_wndView->m_HoldPrim );
5047|  m_wndView->Redraw( false );
5048|}
5049|
5050|void CMainFrame::OnAlignLeft()
5051|{
5052|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
5053|
5054|  app->Align( CadPrim_AlignLeft, &m_wndView->m_MultiHolds,
5055|    m_wndView->m_HoldPrim );
5056|  m_wndView->Redraw( false );
5057|}
5058|
5059|void CMainFrame::OnAlignRight()
5060|{
5061|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
5062|
5063|  app->Align( CadPrim_AlignRight, &m_wndView->m_MultiHolds,
5064|    m_wndView->m_HoldPrim );
5065|  m_wndView->Redraw( false );
5066|}
5067|
5068|void CMainFrame::OnAlignTop()
5069|{
5070|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
5071|
5072|  app->Align( CadPrim_AlignTop, &m_wndView->m_MultiHolds,
5073|    m_wndView->m_HoldPrim );
5074|  m_wndView->Redraw( false );
5075|}
5076|
5077|void CMainFrame::OnAlignBottom()
5078|{
5079|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
5080|
5081|  app->Align( CadPrim_AlignBottom, &m_wndView->m_MultiHolds,
5082|    m_wndView->m_HoldPrim );
5083|  m_wndView->Redraw( false );
5084|}
5085|
5086|void CMainFrame::OnFitSizeHorizontal()
5087|{
5088|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
5089|
5090|  app->FitSize( CadPrim_Horizontal, &m_wndView->m_MultiHolds,
5091|    m_wndView->m_HoldPrim );
5092|  m_wndView->Redraw( false );
5093|}
5094|
5095|void CMainFrame::OnFitSizeVertical()
5096|{
5097|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
5098|
5099|  app->FitSize( CadPrim_Vertical, &m_wndView->m_MultiHolds,
5100|    m_wndView->m_HoldPrim );
5101|  m_wndView->Redraw( false );
5102|}
5103|
5104|void CMainFrame::OnAlignIntervalHorizontal()
5105|{
5106|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
5107|
5108|  app->AlignInterval( CadPrim_Horizontal, &m_wndView->m_MultiHolds );
5109|  m_wndView->Redraw( false );
5110|}
5111|
5112|void CMainFrame::OnAlignIntervalVertical()
5113|{
5114|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
5115|
5116|  app->AlignInterval( CadPrim_Vertical, &m_wndView->m_MultiHolds );
5117|  m_wndView->Redraw( false );
5118|}
5119|
5120|
5121| 
5122|/***********************************************************************
5123|  13-55. <<< [CMainFrame::OnWindowColor] 背景を透明にするを選んだときの処理 >>> 
5124|************************************************************************/
5125|void CMainFrame::OnWindowColor()
5126|{
5127|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
5128|
5129|  app->m_bBackTransparent = ! app->m_bBackTransparent;
5130|
5131|  app->SaveSVGCatsIni();
5132|  Invalidate( FALSE );
5133|}
5134|
5135|
5136| 
5137|/***********************************************************************
5138|  13-56. <<< [CMainFrame::OnDispHTML] 埋め込みHTMLを選んだときの処理 >>> 
5139|************************************************************************/
5140|void CMainFrame::OnDispHTML()
5141|{
5142|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
5143|  CString  s;
5144|
5145|  if ( app->m_path[0] == '\0' ) {
5146|    if ( app->m_bJapanese )  s.LoadString( IDS_NeedFName );
5147|    else  s.LoadString( IDS_NeedFName_E );
5148|
5149|    MessageBox( s, NULL, MB_OK );
5150|  }
5151|  else {
5152|    CDummy  dlg;
5153|    bool  t = app->m_bBackTransparent;
5154|
5155|    dlg.DoModal();
5156|
5157|    if ( t != app->m_bBackTransparent )
5158|      m_wndView->Redraw( false );
5159|  }
5160|}
5161|
5162|
5163| 
5164|/***********************************************************************
5165|  13-57. <<< [CMainFrame::OnPreview] SVGビューアでプレビューを選んだときの処理 >>> 
5166|************************************************************************/
5167|void CMainFrame::OnPreview()
5168|{
5169|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
5170|  char  path[_MAX_PATH];
5171|  char  svgPathBack[_MAX_PATH];
5172|
5173|  StrX_getExeFullPath( path, "system\\preview.svg", sizeof(path) );
5174|  app->Save( path, true );
5175|
5176|  strcpy( svgPathBack, app->m_path );
5177|  strcpy( app->m_path, "system\\preview.svg" );
5178|  strcpy( app->m_path, svgPathBack );
5179|
5180|  StrX_getExeFullPath( path, "system\\preview.html", sizeof(path) );
5181|  app->SaveHtml( path, "preview.svg", "Preview - SVG Cats", 3 );
5182|
5183|  if ( app->m_file.m_CurrentPageNum >= 2 )
5184|    sprintf( strchr( path, '\0' ), "#page%d", app->m_file.m_CurrentPageNum );
5185|
5186|  WinX_openIE( path );
5187|}
5188|
5189|
5190| 
5191|/***********************************************************************
5192|  13-58. <<< [CMainFrame::OnNextPage] 次のページを選んだときの処理 >>> 
5193|************************************************************************/
5194|void CMainFrame::OnNextPage()
5195|{
5196|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
5197|
5198|  if ( app->m_file.m_CurrentPageNum >= SVGCat_File_getMaxPageNum( &app->m_file ) )
5199|    return;
5200|
5201|  ChgPage( app->m_file.m_CurrentPageNum + 1 );
5202|  m_wndView->m_bDisableSwapRec = true;
5203|}
5204|
5205|
5206|void CMainFrame::OnPrevPage()
5207|{
5208|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
5209|
5210|  if ( app->m_file.m_CurrentPageNum <= 1 )  return;
5211|
5212|  ChgPage( app->m_file.m_CurrentPageNum - 1 );
5213|  m_wndView->m_bDisableSwapRec = true;
5214|}
5215|
5216|
5217|void CMainFrame::OnFirstPage()
5218|{
5219|  ChgPage( 1 );
5220|  m_wndView->m_bDisableSwapRec = true;
5221|}
5222|
5223|
5224|void CMainFrame::OnLastPage()
5225|{
5226|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
5227|  int  n = ListX_getN( &app->m_file.m_pages, SVGCat_Page );
5228|
5229|  ChgPage( n - 1 + app->m_file.m_StartPageNum );
5230|  m_wndView->m_bDisableSwapRec = true;
5231|}
5232|
5233|
5234| 
5235|/***********************************************************************
5236|  13-59. <<< [CMainFrame::OnNewPage] 次のページとの間に新しいページを作成する >>> 
5237|************************************************************************/
5238|void CMainFrame::OnNewPage()  /* 下 */
5239|{
5240|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
5241|  CTreeCtrl*  tree = &m_Left->GetTreeCtrl();
5242|  SVGCat_Page*  page;
5243|  HTREEITEM  item, parent;
5244|
5245|  m_wndView->ResetSelect();
5246|  app->NewPage( &app->m_file, 0 );
5247|  m_wndView->Invalidate( FALSE );
5248|  UpdateWindowText();
5249|  ResetProp();
5250|
5251|  page = ListX_get( &app->m_file.m_pages, app->m_file.m_CurrentPageNum - app->m_file.m_StartPageNum, SVGCat_Page );
5252|  app->m_UndoBuf->AllocNewStep_Page( -1, 0, -1, app->m_file.m_CurrentPageNum, -1, NULL );
5253|
5254|  item = tree->GetSelectedItem();
5255|  parent = tree->GetParentItem( item );
5256|  item = tree->InsertItem( page->title, parent, item );
5257|  tree->SetItemData( item, (long)page );
5258|  tree->Select( item, TVGN_CARET );
5259|
5260|  m_ClipPageNum = -1;
5261|
5262|  if ( app->m_SplitMode == 1 )  OnSideByTree();
5263|}
5264|
5265|
5266|
5267|void CMainFrame::OnNewChildPage()  /* 子 */
5268|{
5269|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
5270|  CTreeCtrl*  tree = &m_Left->GetTreeCtrl();
5271|  SVGCat_Page*  page;
5272|  HTREEITEM  item;
5273|
5274|  m_wndView->ResetSelect();
5275|  app->NewPage( &app->m_file, 1 );
5276|  m_wndView->Invalidate( FALSE );
5277|  UpdateWindowText();
5278|  ResetProp();
5279|
5280|  page = ListX_get( &app->m_file.m_pages, app->m_file.m_CurrentPageNum - app->m_file.m_StartPageNum, SVGCat_Page );
5281|  app->m_UndoBuf->AllocNewStep_Page( -1, 1, -1, app->m_file.m_CurrentPageNum, -1, NULL );
5282|
5283|  item = tree->GetSelectedItem();
5284|  item = tree->InsertItem( page->title, item, TVI_FIRST );
5285|  tree->SetItemData( item, (long)page );
5286|  tree->Select( item, TVGN_CARET );
5287|
5288|  m_ClipPageNum = -1;
5289|
5290|  if ( app->m_SplitMode == 1 )  OnSideByTree();
5291|}
5292|
5293|
5294|void CMainFrame::OnNewPrevPage()  /* 上 */
5295|{
5296|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
5297|  CTreeCtrl*  tree = &m_Left->GetTreeCtrl();
5298|  SVGCat_Page*  page;
5299|  HTREEITEM  item, parent;
5300|
5301|  m_wndView->ResetSelect();
5302|  app->NewPage( &app->m_file, 2 );
5303|  m_wndView->Invalidate( FALSE );
5304|  UpdateWindowText();
5305|  ResetProp();
5306|
5307|  page = ListX_get( &app->m_file.m_pages, app->m_file.m_CurrentPageNum - app->m_file.m_StartPageNum, SVGCat_Page );
5308|  app->m_UndoBuf->AllocNewStep_Page( -1, 2, -1, app->m_file.m_CurrentPageNum, -1, NULL );
5309|
5310|  item = tree->GetSelectedItem();
5311|  parent = tree->GetParentItem( item );
5312|  item = tree->GetPrevSiblingItem( item );
5313|  if ( item == NULL )  item = TVI_FIRST;
5314|  item = tree->InsertItem( page->title, parent, item );
5315|  tree->SetItemData( item, (long)page );
5316|  tree->Select( item, TVGN_CARET );
5317|
5318|  m_ClipPageNum = -1;
5319|
5320|  if ( app->m_SplitMode == 1 )  OnSideByTree();
5321|}
5322|
5323|
5324|void CMainFrame::OnMakeBackPage()
5325|{
5326|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
5327|
5328|  m_wndView->ResetSelect();
5329|  app->ChgToBackPage( &app->m_file );
5330|  m_wndView->Invalidate( FALSE );
5331|  m_wndView->SetScrollSize();
5332|  UpdateWindowText();
5333|  ResetProp();
5334|
5335|  if ( app->m_file.m_CurrentPageNum == 0 ) {
5336|    CTreeCtrl*  tree = &m_Left->GetTreeCtrl();
5337|    tree->SelectItem( NULL );
5338|  }
5339|  else {
5340|    m_wndView->ResetSelect();
5341|    app->ChgPage( &app->m_file, app->m_file.m_CurrentPageNum );
5342|    m_wndView->Invalidate( FALSE );
5343|    m_wndView->SetScrollSize();
5344|    UpdateWindowText();
5345|    ResetProp();
5346|  }
5347|
5348|  m_ClipPageNum = -1;
5349|}
5350|
5351|
5352|void CMainFrame::OnImportSVG()
5353|{
5354|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
5355|  CTreeCtrl*  tree = &m_Left->GetTreeCtrl();
5356|  CFileDialog  dlg( TRUE, "svg", NULL, OFN_HIDEREADONLY,
5357|                    app->m_bJapanese ? _svg_read_filter : _svg_read_filterE );
5358|  SVGCat_Page*  page;
5359|  SVGCat_Page*  addedFirstPage;
5360|  SVGCat_Page*  addedLastTopLevelPage;
5361|  HTREEITEM  item, parent;
5362|
5363|  page = ListX_get( &app->m_file.m_pages, app->m_file.m_CurrentPageNum - app->m_file.m_StartPageNum, SVGCat_Page );
5364|
5365|  #ifdef  NDEBUG
5366|    dlg.m_ofn.Flags &= ~OFN_ENABLEHOOK;  /* Win2000以降の新しいファイルダイアログにする */
5367|  #endif
5368|
5369|  if ( dlg.DoModal() != IDOK )
5370|    return;
5371|
5372|  CWaitCursor  wa;
5373|
5374|  app->m_UndoBuf->StartMulti();
5375|  addedFirstPage = app->ImportSVG( &app->m_file, page, dlg.GetPathName(), &addedLastTopLevelPage, NULL );
5376|  app->m_UndoBuf->EndMulti();
5377|
5378|  page = addedLastTopLevelPage->next;  addedLastTopLevelPage->next = NULL;
5379|  item = tree->GetSelectedItem();
5380|  parent = tree->GetParentItem( item );
5381|  item = tree->GetPrevSiblingItem( item );
5382|  item = LoadTree( tree, addedFirstPage, parent, item );
5383|  addedLastTopLevelPage->next = page;
5384|
5385|  tree->Select( item, TVGN_CARET );
5386|
5387|  m_ClipPageNum = -1;
5388|
5389|  if ( app->m_SplitMode == 1 )  OnSideByTree();
5390|}
5391|
5392|
5393| 
5394|/***********************************************************************
5395|  13-60. <<< [CMainFrame::OnDelPage] ページを削除する >>> 
5396|************************************************************************/
5397|void CMainFrame::OnDelPage()
5398|{
5399|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
5400|  CTreeCtrl*  tree = &m_Left->GetTreeCtrl();
5401|  HTREEITEM  item, next;
5402|
5403|  if ( ListX_getN( &app->m_file.m_pages, SVGCat_Page ) + app->m_file.m_StartPageNum - 1 == 1 )
5404|    return;
5405|
5406|  m_wndView->ResetSelect();
5407|  app->DelPage( &app->m_file );
5408|  m_wndView->Invalidate( FALSE );
5409|  UpdateWindowText();
5410|  ResetProp();
5411|
5412|  item = tree->GetSelectedItem();
5413|  next = tree->GetNextSiblingItem( item );
5414|  if ( next == NULL )  next = tree->GetPrevSiblingItem( item );
5415|  if ( next == NULL )  next = tree->GetParentItem( item );
5416|  tree->DeleteItem( item );
5417|  tree->Select( next, TVGN_CARET );
5418|
5419|  m_ClipPageNum = -1;
5420|}
5421|
5422|
5423| 
5424|/***********************************************************************
5425|  13-61. <<< [CMainFrame::OnBackupInterval] 定期バックアップ設定を選んだときの処理 >>> 
5426|************************************************************************/
5427|void CMainFrame::OnBackupInterval()
5428|{
5429|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
5430|  CString  s;
5431|
5432|  if ( m_Timer != 0 )  KillTimer( m_Timer );
5433|
5434|  MessageBox( app->m_bJapanese ?
5435|    "(メモ)定期バックアップ機能は、SVG Cats がハングアップしたときのための機能です。"
5436|    "バックアップは、SVG Cats の実行ファイルがあるフォルダに作成されます。"
5437|    "次の設定ウィンドウで0を設定すると、この機能は無効になります。"
5438|   : "(Memorandom) Periodical backup function is for when SVG Cats hang up. "
5439|    "Backup file is made in the folder of svgcats.exe. "
5440|    "If you want to disable the function, set 0 in the next setting window.",
5441|    "help", MB_OK );
5442|
5443|  if ( app->m_bJapanese )  s.LoadString( IDS_BackupInterval );
5444|  else  s.LoadString( IDS_BackupInterval_E );
5445|
5446| if ( m_wndView->m_InkOverlay != NULL ) {
5447|  CInputIntDlg  dlg;
5448|
5449|  dlg.m_Msg = s;
5450|  dlg.m_Value = app->m_BackupInterval;
5451|  dlg.m_Min = 0;  dlg.m_Max = 90;
5452|  dlg.m_PenInputPanel = m_wndView->m_PenInputPanel;
5453|//  dlg.m_bDispPenPanel = m_wndView->m_bInputML_bDispPenPanel;
5454|
5455|  if ( dlg.DoModal() == IDOK ) {
5456|    app->m_BackupInterval = dlg.m_Value;
5457|    app->SaveSVGCatsIni();
5458|  }
5459|//  m_wndView->m_bInputML_bDispPenPanel = dlg.m_bDispPenPanel;
5460| }
5461| else {
5462|  CInputIntDlg1  dlg;
5463|
5464|  dlg.m_Msg = s;
5465|  dlg.m_Value = app->m_BackupInterval;
5466|  dlg.m_Min = 0;  dlg.m_Max = 90;
5467|  dlg.m_PenInputPanel = m_wndView->m_PenInputPanel;
5468|//  dlg.m_bDispPenPanel = m_wndView->m_bInputML_bDispPenPanel;
5469|
5470|  if ( dlg.DoModal() == IDOK ) {
5471|    app->m_BackupInterval = dlg.m_Value;
5472|    app->SaveSVGCatsIni();
5473|  }
5474|//  m_wndView->m_bInputML_bDispPenPanel = dlg.m_bDispPenPanel;
5475| }
5476|
5477|  if ( app->m_BackupInterval > 0 )
5478|    m_Timer = SetTimer( CMainFrame_Timer_Backup, 60*1000*app->m_BackupInterval, NULL );
5479|  else
5480|    m_Timer = 0;
5481|}
5482|
5483|
5484| 
5485|/***********************************************************************
5486|  13-62. <<< [CMainFrame::OnHelp] ヘルプを選んだときの処理 >>> 
5487|************************************************************************/
5488|void CMainFrame::OnHelp()
5489|{
5490|  char  url[512];
5491|
5492|  StrX_getExeFullPath( url, "説明書.html", sizeof(url) );
5493|  WinX_openIE( url );
5494|}
5495|
5496|void CMainFrame::OnHelpSVG()
5497|{
5498|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
5499|  char  path[512];
5500|  CString  s;
5501|
5502|  m_wndView->OnFinishPrimMove();
5503|
5504|  /* 編集していたら、保存する */
5505|  if ( m_wndView->IsDirty() ) {
5506|    int  r;
5507|
5508|    if ( app->m_bJapanese )  s.LoadString( IDS_SaveConfirm );
5509|    else  s.LoadString( IDS_SaveConfirm_E );
5510|
5511|    ::SetWindowPos( m_hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE );
5512|    r = MessageBox( s, app->m_path, MB_YESNOCANCEL | MB_ICONWARNING );
5513|
5514|    switch ( r ) {
5515|     case  IDYES:  OnSaveOv();  break;
5516|     case  IDCANCEL:  return;
5517|    }
5518|  }
5519|
5520|  /* SVG ファイルを開く */
5521|  StrX_getExeFullPath( path, app->m_bJapanese ? "help.svg" : "help-e.svg", sizeof(path) );
5522|  if ( FileX_isExist( path ) )
5523|    Load( path, false );
5524|  else {
5525|    if ( app->m_bJapanese )  s.LoadString( IDS_NotFound );
5526|    else  s.LoadString( IDS_NotFound_E );
5527|
5528|    MessageBox( s );
5529|  }
5530|  SetDefaultMode();
5531|}
5532|
5533|
5534|void CMainFrame::OnHelpSample()
5535|{
5536|  char  url[512];
5537|
5538|  StrX_getExeFullPath( url, "html/SVGCats.htm#sample", sizeof(url) );
5539|  WinX_openIE( url );
5540|}
5541|
5542|
5543| 
5544|/***********************************************************************
5545|  13-63. <<< [CMainFrame::OnOpenCommercial] 広告を表示する >>> 
5546|************************************************************************/
5547|void CMainFrame::OnOpenCommercial()
5548|{
5549|  char  path[_MAX_PATH];
5550|
5551|  StrX_getExeFullPath( path, "system\\getnewkey.html", sizeof(path) );
5552|  WinX_openHtml( path, true );
5553|}
5554| 
5555|/***********************************************************************
5556|  13-64. <<< [CMainFrame::OnOpenLink] リンクを開く >>> 
5557|************************************************************************/
5558|void CMainFrame::OnOpenLink()
5559|{
5560|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
5561|  char*  url = GetLinkURL();
5562|
5563|  if ( url[0] == '#' ) {
5564|    int  iPage = app->SearchByID( &app->m_file, url+1, NULL );
5565|
5566|    if ( iPage == -1 )
5567|      MessageBox( CString("リンク先") + (url+1) + "が見つかりません" );
5568|    else
5569|      ChgPage( iPage );
5570|  }
5571|  else if ( strncmp( url, "http://", 7 ) == 0 || strncmp( url, "file://", 7 ) == 0 )
5572|    WinX_openHtml( url, true );
5573|  else if ( ! FileX_isExist( url ) ) {
5574|    CString  s;
5575|
5576|    s.LoadString( app->m_bJapanese ? IDS_NotFound : IDS_NotFound_E );
5577|    MessageBox( CString(url) + " " + s, "リンク先エラー", MB_OK );
5578|  }
5579|  else if ( FileX_isDir( url ) )
5580|    WinX_openFolder( url );
5581|  else
5582|    WinX_openFile( url );
5583|}
5584|
5585| 
5586|/***********************************************************************
5587|  13-65. <<< [CMainFrame::OnSaveImage] 画像を保存する >>> 
5588|************************************************************************/
5589|void CMainFrame::OnSaveImage()
5590|{
5591|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
5592|  CChildView*  view = m_wndView;
5593|  const char*  imgPath = ((Rect_Ex*)view->m_HoldPrim)->m_ImgPath;
5594|  const char*  imgWorkPath = ((Rect_Ex*)view->m_HoldPrim)->m_ImgWorkPath;
5595|  char*  ext = StrX_refExt( imgWorkPath );
5596|  char*  filter;
5597|  int  i;
5598|  char  path[_MAX_PATH];
5599|  CString  overStr;
5600|
5601|  if ( app->m_bJapanese )  overStr.LoadString( IDS_SaveOver );
5602|  else  overStr.LoadString( IDS_SaveOver_E );
5603|
5604|  i = 1;
5605|  sprintf( path, "%s\\image01.%s", app->m_SaveFolderPath, ext );
5606|  while ( FileX_isExist( path ) ) {
5607|    i++;
5608|    sprintf( path, "%s\\image%02d.%s", app->m_SaveFolderPath, i, ext );
5609|  }
5610|
5611|  if ( stricmp( ext, "jpg" ) == 0 || stricmp( ext, "jpeg" ) == 0 )
5612|    { filter = app->m_bJapanese ? _jpg_filter : _jpg_filterE; }
5613|  else if ( stricmp( ext, "png" ) == 0 )
5614|    { filter = app->m_bJapanese ? _png_filter : _png_filterE; }
5615|  else if ( stricmp( ext, "gif" ) == 0 )
5616|    { filter = app->m_bJapanese ? _gif_filter : _gif_filterE; }
5617|  else
5618|    { filter = app->m_bJapanese ? _any_filter : _any_filterE; }
5619|
5620|
5621|  CFileDialog  dlg( FALSE, ext, path, OFN_HIDEREADONLY | OFN_EXPLORER, filter );
5622|
5623|  #ifdef  NDEBUG
5624|    dlg.m_ofn.Flags &= ~OFN_ENABLEHOOK;  /* Win2000以降の新しいファイルダイアログにする */
5625|  #endif
5626|
5627|  dlg.m_ofn.lpstrInitialDir = app->m_SaveFolderPath;
5628|
5629|  for (;;) {
5630|    if ( dlg.DoModal() == IDOK ) {
5631|      if ( FileX_isExist( dlg.GetPathName() ) ) {
5632|        if ( MessageBox( overStr, NULL, MB_YESNO | MB_DEFBUTTON2 ) == IDNO )
5633|          continue;
5634|      }
5635|
5636|      StrX_cpyFolder( app->m_SaveFolderPath, dlg.GetPathName() );
5637|      app->SaveSVGCatsIni( false );
5638|
5639|      if ( ((Rect_Ex*)view->m_HoldPrim)->m_bEmbedImg )
5640|        FileX_copy( dlg.GetPathName(), imgWorkPath );
5641|      else
5642|        FileX_copy( dlg.GetPathName(), imgPath );
5643|    }
5644|    break;
5645|  }
5646|}
5647|
5648|void CMainFrame::OnUpdateSaveImage(CCmdUI* pCmdUI)
5649|{
5650|  CChildView*  view = m_wndView;
5651|
5652|  if ( view->m_HoldPrim != NULL && view->m_HoldPrim->GetTypeID() == Rect_Ex_TypeID ) {
5653|    Rect_Ex*  r = (Rect_Ex*)view->m_HoldPrim;
5654|
5655|    if ( r->m_bEmbedImg )
5656|      pCmdUI->Enable( FileX_isExist( r->m_ImgWorkPath ) );
5657|    else
5658|      pCmdUI->Enable( FileX_isExist( r->m_ImgPath ) );
5659|  }
5660|  else
5661|    pCmdUI->Enable( FALSE );
5662|}
5663| 
5664|/*-------------------------------------------------------------------------*/
5665|/* 14. <<<< ◆ツールバー >>>>  */ 
5666|/*-------------------------------------------------------------------------*/
5667|
5668|
5669| 
5670|/***********************************************************************
5671|  14-1. <<< ツールバーのボタンを押したときの処理 >>> 
5672|************************************************************************/
5673|
5674|void CMainFrame::SetDefaultMode()
5675|{
5676|  if ( m_mode != CMainFrame_Select && !IsPenMode() ) {
5677|    m_mode = CMainFrame_Select;
5678|    UpdateCreateToolBar( ID_Select, &m_CreateBar, true );
5679|    m_wndView->m_Cursor = LoadCursor( NULL, IDC_CROSS );
5680|  }
5681|}
5682|
5683|
5684|bool CMainFrame::IsPenMode()
5685|{
5686|  return  ( m_mode == CMainFrame_UseInk || m_mode == CMainFrame_UseRedInk ||
5687|            m_mode == CMainFrame_UseBlueInk || m_mode == CMainFrame_UseMarker ||
5688|            m_mode == CMainFrame_UseRedMarker || m_mode == CMainFrame_UseYellowMarker ||
5689|            m_mode == CMainFrame_UseRope );
5690|}
5691|
5692|bool CMainFrame::CanPaste( bool bStyle )
5693|{
5694|  HGLOBAL  data = 0;
5695|  void*  data_ptr;
5696|  VARIANT_BOOL  bCanInkPaste;
5697|  bool  bExistData;
5698|
5699|/*
5700|  if ( m_wndSplitter.GetActivePane() == m_Left ) {
5701|    if ( OpenClipboard() ) {
5702|      void* p;
5703|
5704|      data = GetClipboardData( SVGCats_ClipFormat );
5705|      p = GlobalLock( data );
5706|      bExistData = ( p != NULL && ( *((int*)p + 1) & 1 ) );
5707|      GlobalUnlock( data );
5708|      CloseClipboard();
5709|      return  bExistData;
5710|    }
5711|    else
5712|      return  false;
5713|  }
5714|*/
5715|
5716|//  else {
5717|    if ( OpenClipboard() ) {
5718|      data = GetClipboardData( SVGCats_ClipFormat );
5719|      bExistData = (data != 0);
5720|      if ( bStyle ) {
5721|        if ( bExistData ) {
5722|          data_ptr = GlobalLock( data );
5723|          if ( *((int*)data_ptr + 1) & 1 )  bExistData = false;
5724|          GlobalUnlock( data_ptr );
5725|        }
5726|      }
5727|      else {
5728|        data = GetClipboardData( CF_TEXT );
5729|        bExistData |= (data != 0);
5730|        data = GetClipboardData( CF_BITMAP );
5731|        bExistData |= (data != 0);
5732|        data = GetClipboardData( CF_HDROP );
5733|        bExistData |= (data != 0);
5734|      }
5735|      CloseClipboard();
5736|    }
5737|
5738|    if ( m_wndView->m_InkOverlay != NULL ) {
5739|      HRESULT  hr;
5740|      IInkDisp*  ink;
5741|
5742|      hr = m_wndView->m_InkOverlay->get_Ink( &ink );
5743|      if ( hr != 0 )  error();
5744|
5745|      hr = ink->CanPaste( NULL, &bCanInkPaste );
5746|      if ( hr != 0 )  error();
5747|
5748|      ink->Release();  ink = NULL;
5749|    }
5750|    else
5751|      bCanInkPaste = false;
5752|
5753|    return  bExistData || bCanInkPaste;
5754|//  }
5755|}
5756|
5757|
5758|void CMainFrame::SetMode( int mode )
5759|{
5760|  switch ( mode ) {
5761|    case  CMainFrame_Select:  OnSelect();  break;
5762|    case  CMainFrame_SelectMulti:  OnSelectMulti();  break;
5763|    case  CMainFrame_Rotate:  OnRotate();  break;
5764|    case  CMainFrame_CreateText:  OnCreateText();  break;
5765|    case  CMainFrame_CreateRedText:  OnCreateRedText();  break;
5766|    case  CMainFrame_CreateBlueText:  OnCreateBlueText();  break;
5767|    case  CMainFrame_CreateTimeStamp:  OnCreateTimeStamp();  break;
5768|    case  CMainFrame_CreateTextBox:  OnCreateTextBox();  break;
5769|    case  CMainFrame_CreateTextRound:  OnCreateTextRound();  break;
5770|    case  CMainFrame_CreateTextCircle:  OnCreateTextCircle();  break;
5771|    case  CMainFrame_CreateTextDiamond:  OnCreateTextDiamond();  break;
5772|    case  CMainFrame_CreateTextParal:  OnCreateTextParal();  break;
5773|    case  CMainFrame_CreateLine:  OnCreateLine();  break;
5774|    case  CMainFrame_CreateArrow:  OnCreateArrow();  break;
5775|    case  CMainFrame_CreateLineCorner:  OnCreateLineCorner();  break;
5776|    case  CMainFrame_CreateMatome:  OnCreateMatome();  break;
5777|    case  CMainFrame_CreateGuideLine:  OnCreateGuideLine();  break;
5778|    case  CMainFrame_CreateTransCircle:  OnCreateTransCircle();  break;
5779|    case  CMainFrame_CreateRect:  OnCreateRect();  break;
5780|    case  CMainFrame_CreateRoundRect:  OnCreateRoundRect();  break;
5781|    case  CMainFrame_CreateCircle:  OnCreateCircle();  break;
5782|    case  CMainFrame_CreateDiamond:  OnCreateDiamond();  break;
5783|    case  CMainFrame_CreateImage:  OnCreateImage2();  break;
5784|    case  CMainFrame_UseInk:  OnInk();  break;
5785|    case  CMainFrame_UseRedInk:  OnRedInk();  break;
5786|    case  CMainFrame_UseBlueInk:  OnBlueInk();  break;
5787|    case  CMainFrame_UseMarker:  OnMarker();  break;
5788|    case  CMainFrame_UseRedMarker:  OnRedMarker();  break;
5789|    case  CMainFrame_UseYellowMarker:  OnYellowMarker();  break;
5790|    case  CMainFrame_UseRope:  OnRope();  break;
5791|  }
5792|}
5793|
5794|void CMainFrame::OnSelect()
5795|{
5796|  int  prevMode = m_mode;
5797|  bool  bDisableResetSelect = ( prevMode == CMainFrame_UseRope || IsPenMode() );
5798|
5799|  if ( m_mode == CMainFrame_Zooming )  m_wndView->Redraw( true );
5800|  m_mode = CMainFrame_Select;
5801|  UpdateCreateToolBar( ID_Select, &m_CreateBar, true, bDisableResetSelect );
5802|  UpdateCreateToolBar( ID_Select, &m_PenBar, false, bDisableResetSelect );
5803|
5804|  if ( ! bDisableResetSelect ) {
5805|    m_wndView->ResetSelect();
5806|    m_wndView->Redraw( true );
5807|  }
5808|}
5809|
5810|
5811|void CMainFrame::OnRotate()
5812|{
5813|  if ( m_mode == CMainFrame_Zooming )  m_wndView->Redraw( true );
5814|  m_mode = CMainFrame_Rotate;
5815|  UpdateCreateToolBar( ID_Rotate, &m_CreateBar, true );
5816|}
5817|
5818|void CMainFrame::OnCreateLine()
5819|{
5820|  if ( m_mode == CMainFrame_Zooming )  m_wndView->Redraw( true );
5821|  m_mode = CMainFrame_CreateLine;
5822|  UpdateCreateToolBar( ID_CreateLine, &m_CreateBar, true );
5823|}
5824|
5825|
5826|void CMainFrame::OnCreateArrow()
5827|{
5828|  if ( m_mode == CMainFrame_Zooming )  m_wndView->Redraw( true );
5829|  m_mode = CMainFrame_CreateArrow;
5830|  UpdateCreateToolBar( ID_CreateArrow, &m_CreateBar, true );
5831|}
5832|
5833|void CMainFrame::OnCreateLineCorner()
5834|{
5835|  if ( m_mode == CMainFrame_Zooming )  m_wndView->Redraw( true );
5836|  m_mode = CMainFrame_CreateLineCorner;
5837|  UpdateCreateToolBar( ID_CreateLineCorner, &m_CreateBar, true );
5838|}
5839|
5840|
5841|void CMainFrame::OnCreateMatome()
5842|{
5843|  if ( m_mode == CMainFrame_Zooming )  m_wndView->Redraw( true );
5844|  m_mode = CMainFrame_CreateMatome;
5845|  UpdateCreateToolBar( ID_CreateMatome, &m_CreateBar, true );
5846|}
5847|
5848|void CMainFrame::OnCreateGuideLine()
5849|{
5850|  if ( m_mode == CMainFrame_Zooming )  m_wndView->Redraw( true );
5851|  m_mode = CMainFrame_CreateGuideLine;
5852|  UpdateCreateToolBar( ID_CreateGuideLine, &m_CreateBar, true );
5853|}
5854|
5855|void CMainFrame::OnCreateRect()
5856|{
5857|  if ( m_mode == CMainFrame_Zooming )  m_wndView->Redraw( true );
5858|  m_mode = CMainFrame_CreateRect;
5859|  UpdateCreateToolBar( ID_CreateRect, &m_CreateBar, true );
5860|}
5861|
5862|void CMainFrame::OnCreateRoundRect()
5863|{
5864|  if ( m_mode == CMainFrame_Zooming )  m_wndView->Redraw( true );
5865|  m_mode = CMainFrame_CreateRoundRect;
5866|  UpdateCreateToolBar( ID_CreateRoundRect, &m_CreateBar, true );
5867|}
5868|
5869|void CMainFrame::OnCreateCircle()
5870|{
5871|  if ( m_mode == CMainFrame_Zooming )  m_wndView->Redraw( true );
5872|  m_mode = CMainFrame_CreateCircle;
5873|  UpdateCreateToolBar( ID_CreateCircle, &m_CreateBar, true );
5874|}
5875|
5876|void CMainFrame::OnCreateTransCircle()
5877|{
5878|  if ( m_mode == CMainFrame_Zooming )  m_wndView->Redraw( true );
5879|  m_mode = CMainFrame_CreateTransCircle;
5880|  UpdateCreateToolBar( ID_CreateTransCircle, &m_PenBar, true );
5881|}
5882|
5883|void CMainFrame::OnCreateDiamond()
5884|{
5885|  if ( m_mode == CMainFrame_Zooming )  m_wndView->Redraw( true );
5886|  m_mode = CMainFrame_CreateDiamond;
5887|  UpdateCreateToolBar( ID_CreateDiamond, &m_CreateBar, true );
5888|}
5889|
5890|void CMainFrame::OnCreateImage2()
5891|{
5892|  if ( m_mode == CMainFrame_Zooming )  m_wndView->Redraw( true );
5893|  m_mode = CMainFrame_CreateImage;
5894|  UpdateCreateToolBar( ID_CreateImage2, &m_CreateBar, true );
5895|}
5896|
5897|
5898|void CMainFrame::OnCreateText()
5899|{
5900|  if ( m_mode == CMainFrame_Zooming )  m_wndView->Redraw( true );
5901|  m_mode = CMainFrame_CreateText;
5902|  UpdateCreateToolBar( ID_CreateText, &m_CreateBar, true );
5903|  UpdateCreateToolBar( ID_CreateText, &m_PenBar, false );
5904|}
5905|
5906|void CMainFrame::OnCreateRedText()
5907|{
5908|  if ( m_mode == CMainFrame_Zooming )  m_wndView->Redraw( true );
5909|  m_mode = CMainFrame_CreateRedText;
5910|  UpdateCreateToolBar( ID_CreateRedText, &m_PenBar, false );
5911|}
5912|
5913|void CMainFrame::OnCreateBlueText()
5914|{
5915|  if ( m_mode == CMainFrame_Zooming )  m_wndView->Redraw( true );
5916|  m_mode = CMainFrame_CreateBlueText;
5917|  UpdateCreateToolBar( ID_CreateBlueText, &m_PenBar, false );
5918|}
5919|
5920|
5921|void CMainFrame::OnCreateTimeStamp()
5922|{
5923|  if ( m_mode == CMainFrame_Zooming )  m_wndView->Redraw( true );
5924|  m_mode = CMainFrame_CreateTimeStamp;
5925|  UpdateCreateToolBar( ID_CreateTimeStamp, &m_PenBar, false );
5926|}
5927|
5928|void CMainFrame::OnUpdateCreateTimeStamp(CCmdUI* pCmdUI)
5929|{
5930|    // TODO: この位置に command update UI ハンドラ用のコードを追加してください
5931|
5932|}
5933|void CMainFrame::OnCreateTextBox()
5934|{
5935|  if ( m_mode == CMainFrame_Zooming )  m_wndView->Redraw( true );
5936|  m_mode = CMainFrame_CreateTextBox;
5937|  UpdateCreateToolBar( ID_CreateTextBox, &m_CreateBar, true );
5938|}
5939|
5940|void CMainFrame::OnCreateTextRound()
5941|{
5942|  if ( m_mode == CMainFrame_Zooming )  m_wndView->Redraw( true );
5943|  m_mode = CMainFrame_CreateTextRound;
5944|  UpdateCreateToolBar( ID_CreateTextRound, &m_CreateBar, true );
5945|}
5946|
5947|void CMainFrame::OnCreateTextCircle()
5948|{
5949|  if ( m_mode == CMainFrame_Zooming )  m_wndView->Redraw( true );
5950|  m_mode = CMainFrame_CreateTextCircle;
5951|  UpdateCreateToolBar( ID_CreateTextCircle, &m_CreateBar, true );
5952|}
5953|
5954|void CMainFrame::OnCreateTextDiamond()
5955|{
5956|  if ( m_mode == CMainFrame_Zooming )  m_wndView->Redraw( true );
5957|  m_mode = CMainFrame_CreateTextDiamond;
5958|  UpdateCreateToolBar( ID_CreateTextDiamond, &m_CreateBar, true );
5959|}
5960|
5961|void CMainFrame::OnCreateTextParal()
5962|{
5963|  if ( m_mode == CMainFrame_Zooming )  m_wndView->Redraw( true );
5964|  m_mode = CMainFrame_CreateTextParal;
5965|  UpdateCreateToolBar( ID_CreateTextParal, &m_CreateBar, true );
5966|}
5967|
5968|
5969|void CMainFrame::OnSelectMulti()
5970|{
5971|  if ( m_mode == CMainFrame_Zooming )  m_wndView->Redraw( true );
5972|  m_mode = CMainFrame_SelectMulti;
5973|  UpdateCreateToolBar( ID_SelectMulti, &m_PenBar, true );
5974|
5975|  m_wndView->Redraw( true );
5976|}
5977|
5978|
5979|void CMainFrame::OnInk()
5980|{
5981|  if ( m_mode == CMainFrame_Zooming )  m_wndView->Redraw( true );
5982|  m_mode = CMainFrame_UseInk;
5983|  UpdateCreateToolBar( ID_Ink, &m_PenBar, false );
5984|  m_wndView->ResetSelect();
5985|
5986|  #ifdef  USES_InkOverlay
5987|  {
5988|    HRESULT  hr;
5989|
5990|    hr = m_wndView->m_InkOverlay->putref_DefaultDrawingAttributes( m_wndView->m_PenAttr );
5991|    if ( hr != 0 )  error();
5992|    hr = m_wndView->m_InkOverlay->put_Enabled( VARIANT_TRUE );
5993|    if ( hr != 0 )  error();
5994|    hr = m_wndView->m_InkOverlay->put_EditingMode( IOEM_Ink );
5995|    if ( hr != 0 )  error();
5996|    hr = m_wndView->m_InkOverlay->put_MousePointer( IMP_Default );
5997|    if ( hr != 0 )  error();
5998|    m_wndView->m_bMyInkSelectMode = false;
5999|  }
6000|  #endif
6001|}
6002|
6003|
6004|
6005|void CMainFrame::OnRedInk()
6006|{
6007|  if ( m_mode == CMainFrame_Zooming )  m_wndView->Redraw( true );
6008|  m_mode = CMainFrame_UseRedInk;
6009|  UpdateCreateToolBar( ID_RedInk, &m_PenBar, false );
6010|  m_wndView->ResetSelect();
6011|
6012|  #ifdef  USES_InkOverlay
6013|  {
6014|    HRESULT  hr;
6015|
6016|    hr = m_wndView->m_InkOverlay->putref_DefaultDrawingAttributes( m_wndView->m_RedPenAttr );
6017|    if ( hr != 0 )  error();
6018|    hr = m_wndView->m_InkOverlay->put_Enabled( VARIANT_TRUE );
6019|    if ( hr != 0 )  error();
6020|    hr = m_wndView->m_InkOverlay->put_EditingMode( IOEM_Ink );
6021|    if ( hr != 0 )  error();
6022|    hr = m_wndView->m_InkOverlay->put_MousePointer( IMP_Default );
6023|    if ( hr != 0 )  error();
6024|    m_wndView->m_bMyInkSelectMode = false;
6025|  }
6026|  #endif
6027|}
6028|
6029|
6030|void CMainFrame::OnBlueInk()
6031|{
6032|  if ( m_mode == CMainFrame_Zooming )  m_wndView->Redraw( true );
6033|  m_mode = CMainFrame_UseBlueInk;
6034|  UpdateCreateToolBar( ID_BlueInk, &m_PenBar, false );
6035|  m_wndView->ResetSelect();
6036|
6037|  #ifdef  USES_InkOverlay
6038|  {
6039|    HRESULT  hr;
6040|
6041|    hr = m_wndView->m_InkOverlay->putref_DefaultDrawingAttributes( m_wndView->m_BluePenAttr );
6042|    if ( hr != 0 )  error();
6043|    hr = m_wndView->m_InkOverlay->put_Enabled( VARIANT_TRUE );
6044|    if ( hr != 0 )  error();
6045|    hr = m_wndView->m_InkOverlay->put_EditingMode( IOEM_Ink );
6046|    if ( hr != 0 )  error();
6047|    hr = m_wndView->m_InkOverlay->put_MousePointer( IMP_Default );
6048|    if ( hr != 0 )  error();
6049|    m_wndView->m_bMyInkSelectMode = false;
6050|  }
6051|  #endif
6052|}
6053|
6054|
6055|void CMainFrame::OnMarker()
6056|{
6057|  if ( m_mode == CMainFrame_Zooming )  m_wndView->Redraw( true );
6058|  m_mode = CMainFrame_UseMarker;
6059|  UpdateCreateToolBar( ID_Marker, &m_PenBar, false );
6060|  m_wndView->ResetSelect();
6061|
6062|  #ifdef  USES_InkOverlay
6063|  {
6064|    HRESULT  hr;
6065|
6066|    hr = m_wndView->m_InkOverlay->putref_DefaultDrawingAttributes( m_wndView->m_MarkerAttr );
6067|    if ( hr != 0 )  error();
6068|    hr = m_wndView->m_InkOverlay->put_Enabled( VARIANT_TRUE );
6069|    if ( hr != 0 )  error();
6070|    hr = m_wndView->m_InkOverlay->put_EditingMode( IOEM_Ink );
6071|    if ( hr != 0 )  error();
6072|    hr = m_wndView->m_InkOverlay->put_MousePointer( IMP_Default );
6073|    if ( hr != 0 )  error();
6074|    m_wndView->m_bMyInkSelectMode = false;
6075|  }
6076|  #endif
6077|}
6078|
6079|
6080|void CMainFrame::OnRedMarker()
6081|{
6082|  if ( m_mode == CMainFrame_Zooming )  m_wndView->Redraw( true );
6083|  m_mode = CMainFrame_UseRedMarker;
6084|  UpdateCreateToolBar( ID_RedMarker, &m_PenBar, false );
6085|  m_wndView->ResetSelect();
6086|
6087|  #ifdef  USES_InkOverlay
6088|  {
6089|    HRESULT  hr;
6090|
6091|    hr = m_wndView->m_InkOverlay->putref_DefaultDrawingAttributes( m_wndView->m_RedMarkerAttr );
6092|    if ( hr != 0 )  error();
6093|    hr = m_wndView->m_InkOverlay->put_Enabled( VARIANT_TRUE );
6094|    if ( hr != 0 )  error();
6095|    hr = m_wndView->m_InkOverlay->put_EditingMode( IOEM_Ink );
6096|    if ( hr != 0 )  error();
6097|    hr = m_wndView->m_InkOverlay->put_MousePointer( IMP_Default );
6098|    if ( hr != 0 )  error();
6099|    m_wndView->m_bMyInkSelectMode = false;
6100|  }
6101|  #endif
6102|}
6103|
6104|
6105|void CMainFrame::OnYellowMarker()
6106|{
6107|  if ( m_mode == CMainFrame_Zooming )  m_wndView->Redraw( true );
6108|  m_mode = CMainFrame_UseYellowMarker;
6109|  UpdateCreateToolBar( ID_YellowMarker, &m_PenBar, false );
6110|  m_wndView->ResetSelect();
6111|
6112|  #ifdef  USES_InkOverlay
6113|  {
6114|    HRESULT  hr;
6115|
6116|    hr = m_wndView->m_InkOverlay->putref_DefaultDrawingAttributes( m_wndView->m_YellowMarkerAttr );
6117|    if ( hr != 0 )  error();
6118|    hr = m_wndView->m_InkOverlay->put_Enabled( VARIANT_TRUE );
6119|    if ( hr != 0 )  error();
6120|    hr = m_wndView->m_InkOverlay->put_EditingMode( IOEM_Ink );
6121|    if ( hr != 0 )  error();
6122|    hr = m_wndView->m_InkOverlay->put_MousePointer( IMP_Default );
6123|    if ( hr != 0 )  error();
6124|    m_wndView->m_bMyInkSelectMode = false;
6125|  }
6126|  #endif
6127|}
6128|
6129|
6130|void CMainFrame::OnRope() /* Lasso */
6131|{
6132|  if ( m_mode == CMainFrame_Zooming )  m_wndView->Redraw( true );
6133|  m_mode = CMainFrame_UseRope;
6134|  UpdateCreateToolBar( ID_Rope, &m_PenBar, false );
6135|  m_wndView->ResetSelect();
6136|  m_wndView->m_RopeLeaderPos.x = -99999;
6137|  m_wndView->m_RopeLeaderPos.y = -99999;
6138|  m_wndView->m_RopeNPoint = 0;
6139|  m_wndView->m_RopeTimer = SetTimer( CMainFrame_Timer_DrawRope, 100, NULL );
6140|
6141|  #ifdef  USES_InkOverlay
6142|  {
6143|    HRESULT  hr;
6144|
6145|    #if 1
6146|      hr = m_wndView->m_InkOverlay->putref_DefaultDrawingAttributes( m_wndView->m_SelectPenAttr );
6147|      if ( hr != 0 )  error();
6148|      hr = m_wndView->m_InkOverlay->put_Enabled( VARIANT_TRUE );
6149|      if ( hr != 0 )  error();
6150|      hr = m_wndView->m_InkOverlay->put_EditingMode( IOEM_Ink );
6151|      if ( hr != 0 )  error();
6152|      hr = m_wndView->m_InkOverlay->put_DynamicRendering( VARIANT_FALSE );  /* DC の描画を許す */
6153|      if ( hr != 0 )  error();
6154|      hr = m_wndView->m_InkOverlay->put_MousePointer( IMP_Crosshair );
6155|      if ( hr != 0 )  error();
6156|      m_wndView->m_bMyInkSelectMode = true;
6157|    #else
6158|      /* 以下は描画が遅すぎるため却下 */
6159|      hr = m_wndView->m_InkOverlay->putref_DefaultDrawingAttributes( m_wndView->m_PenAttr );
6160|      if ( hr != 0 )  error();
6161|      hr = m_wndView->m_InkOverlay->put_Enabled( VARIANT_TRUE );
6162|      if ( hr != 0 )  error();
6163|      hr = m_wndView->m_InkOverlay->put_EditingMode( IOEM_Select );
6164|      if ( hr != 0 )  error();
6165|    #endif
6166|  }
6167|  #endif
6168|}
6169|
6170|void CMainFrame::OnEraser()
6171|{
6172|  /* ロープでインクを選択中のときは、インクを消す */
6173|  if ( m_mode == CMainFrame_UseRope ) {
6174|    HRESULT  hr;
6175|    IInkStrokes*  selection;
6176|    IInkDisp*  ink;
6177|    long  n;
6178|
6179|    hr = m_wndView->m_InkOverlay->get_Ink( &ink );
6180|    if ( hr != 0 )  error();
6181|
6182|    hr = m_wndView->m_InkOverlay->get_Selection( &selection );
6183|    if ( hr != 0 )  error();
6184|
6185|    hr = selection->get_Count( &n );
6186|    if ( hr != 0 )  error();
6187|
6188|    selection->Release();  selection = NULL;
6189|    ink->Release();  ink = NULL;
6190|
6191|    if ( n > 0 ) {
6192|      m_wndView->OnDel();
6193|      return;
6194|    }
6195|  }
6196|  if ( m_mode == CMainFrame_Zooming )  m_wndView->Redraw( true );
6197|  m_mode = CMainFrame_UseInk;
6198|  UpdateCreateToolBar( ID_Eraser, &m_PenBar, false );
6199|  m_wndView->ResetSelect();
6200|
6201|  #ifdef  USES_InkOverlay
6202|  {
6203|    HRESULT  hr;
6204|
6205|    hr = m_wndView->m_InkOverlay->putref_DefaultDrawingAttributes( m_wndView->m_PenAttr );
6206|    if ( hr != 0 )  error();
6207|    hr = m_wndView->m_InkOverlay->put_Enabled( VARIANT_TRUE );
6208|    if ( hr != 0 )  error();
6209|    hr = m_wndView->m_InkOverlay->put_EditingMode( IOEM_Delete );
6210|    if ( hr != 0 )  error();
6211|    hr = m_wndView->m_InkOverlay->put_MousePointer( IMP_Default );
6212|    if ( hr != 0 )  error();
6213|    m_wndView->m_bMyInkSelectMode = false;
6214|  }
6215|  #endif
6216|}
6217|
6218|void  CMainFrame::UpdateCreateToolBar( int id_checked, CToolBar* bar, bool bEnableStrongCreate,
6219|  bool bDisableResetSelect )
6220|{
6221|  static  int count = 0;
6222|  static  int count_id = 0;
6223|  int  i;
6224|
6225|  /* ボタン id_checked を選択状態にする */
6226|  if ( GetTickCount() - count < GetDoubleClickTime() &&
6227|       bEnableStrongCreate &&
6228|       id_checked != ID_Select && id_checked == count_id ) {
6229|    i = bar->CommandToIndex( id_checked );
6230|    bar->SetButtonStyle( i, TBBS_PRESSED );
6231|    m_bStrongCreate = true;
6232|    m_wndView->m_bFirstCreate = TRUE;
6233|  }
6234|  else {
6235|    i = bar->CommandToIndex( id_checked );
6236|    bar->SetButtonStyle( i, TBBS_CHECKED );
6237|    if ( id_checked != ID_Select )  m_wndView->m_bFirstCreate = TRUE;
6238|    m_bStrongCreate = false;
6239|  }
6240|  count = GetTickCount();
6241|  count_id = id_checked;
6242|
6243|
6244|  /* 選択していないボタンを元に戻す */
6245|  if ( id_checked != ID_Select ) {
6246|    i = m_CreateBar.CommandToIndex( ID_Select );
6247|    m_CreateBar.SetButtonStyle( i, 0 );
6248|    i = m_PenBar.CommandToIndex( ID_Select );
6249|    m_PenBar.SetButtonStyle( i, 0 );
6250|  }
6251|  if ( id_checked != ID_Rotate ) {
6252|    i = m_CreateBar.CommandToIndex( ID_Rotate );
6253|    m_CreateBar.SetButtonStyle( i, 0 );
6254|  }
6255|  if ( id_checked != ID_CreateText ) {
6256|    i = m_CreateBar.CommandToIndex( ID_CreateText );
6257|    m_CreateBar.SetButtonStyle( i, 0 );
6258|    i = m_PenBar.CommandToIndex( ID_CreateText );
6259|    m_PenBar.SetButtonStyle( i, 0 );
6260|  }
6261|  if ( id_checked != ID_CreateRedText ) {
6262|    i = m_PenBar.CommandToIndex( ID_CreateRedText );
6263|    m_PenBar.SetButtonStyle( i, 0 );
6264|  }
6265|  if ( id_checked != ID_CreateBlueText ) {
6266|    i = m_PenBar.CommandToIndex( ID_CreateBlueText );
6267|    m_PenBar.SetButtonStyle( i, 0 );
6268|  }
6269|  if ( id_checked != ID_CreateTimeStamp ) {
6270|    i = m_PenBar.CommandToIndex( ID_CreateTimeStamp );
6271|    m_PenBar.SetButtonStyle( i, 0 );
6272|  }
6273|  if ( id_checked != ID_CreateTextBox ) {
6274|    i = m_CreateBar.CommandToIndex( ID_CreateTextBox );
6275|    m_CreateBar.SetButtonStyle( i, 0 );
6276|  }
6277|  if ( id_checked != ID_CreateTextRound ) {
6278|    i = m_CreateBar.CommandToIndex( ID_CreateTextRound );
6279|    m_CreateBar.SetButtonStyle( i, 0 );
6280|  }
6281|  if ( id_checked != ID_CreateTextCircle ) {
6282|    i = m_CreateBar.CommandToIndex( ID_CreateTextCircle );
6283|    m_CreateBar.SetButtonStyle( i, 0 );
6284|  }
6285|  if ( id_checked != ID_CreateTextDiamond ) {
6286|    i = m_CreateBar.CommandToIndex( ID_CreateTextDiamond );
6287|    m_CreateBar.SetButtonStyle( i, 0 );
6288|  }
6289|  if ( id_checked != ID_CreateTextParal ) {
6290|    i = m_CreateBar.CommandToIndex( ID_CreateTextParal );
6291|    m_CreateBar.SetButtonStyle( i, 0 );
6292|  }
6293|  if ( id_checked != ID_CreateLine ) {
6294|    i = m_CreateBar.CommandToIndex( ID_CreateLine );
6295|    m_CreateBar.SetButtonStyle( i, 0 );
6296|  }
6297|  if ( id_checked != ID_CreateArrow ) {
6298|    i = m_CreateBar.CommandToIndex( ID_CreateArrow );
6299|    m_CreateBar.SetButtonStyle( i, 0 );
6300|  }
6301|  if ( id_checked != ID_CreateLineCorner ) {
6302|    i = m_CreateBar.CommandToIndex( ID_CreateLineCorner );
6303|    m_CreateBar.SetButtonStyle( i, 0 );
6304|  }
6305|  if ( id_checked != ID_CreateMatome ) {
6306|    i = m_CreateBar.CommandToIndex( ID_CreateMatome );
6307|    m_CreateBar.SetButtonStyle( i, 0 );
6308|  }
6309|  if ( id_checked != ID_CreateGuideLine ) {
6310|    i = m_CreateBar.CommandToIndex( ID_CreateGuideLine );
6311|    m_CreateBar.SetButtonStyle( i, 0 );
6312|  }
6313|  if ( id_checked != ID_CreateRect ) {
6314|    i = m_CreateBar.CommandToIndex( ID_CreateRect );
6315|    m_CreateBar.SetButtonStyle( i, 0 );
6316|  }
6317|  if ( id_checked != ID_CreateRoundRect ) {
6318|    i = m_CreateBar.CommandToIndex( ID_CreateRoundRect );
6319|    m_CreateBar.SetButtonStyle( i, 0 );
6320|  }
6321|  if ( id_checked != ID_CreateCircle ) {
6322|    i = m_CreateBar.CommandToIndex( ID_CreateCircle );
6323|    m_CreateBar.SetButtonStyle( i, 0 );
6324|  }
6325|  if ( id_checked != ID_CreateTransCircle ) {
6326|    i = m_PenBar.CommandToIndex( ID_CreateTransCircle );
6327|    m_PenBar.SetButtonStyle( i, 0 );
6328|  }
6329|  if ( id_checked != ID_CreateDiamond ) {
6330|    i = m_CreateBar.CommandToIndex( ID_CreateDiamond );
6331|    m_CreateBar.SetButtonStyle( i, 0 );
6332|  }
6333|  if ( id_checked != ID_CreateImage2 ) {
6334|    i = m_CreateBar.CommandToIndex( ID_CreateImage2 );
6335|    m_CreateBar.SetButtonStyle( i, 0 );
6336|  }
6337|  if ( id_checked != ID_SelectMulti ) {
6338|    i = m_PenBar.CommandToIndex( ID_SelectMulti );
6339|    m_PenBar.SetButtonStyle( i, 0 );
6340|  }
6341|  if ( id_checked != ID_Ink ) {
6342|    i = m_PenBar.CommandToIndex( ID_Ink );
6343|    m_PenBar.SetButtonStyle( i, 0 );
6344|  }
6345|  if ( id_checked != ID_RedInk ) {
6346|    i = m_PenBar.CommandToIndex( ID_RedInk );
6347|    m_PenBar.SetButtonStyle( i, 0 );
6348|  }
6349|  if ( id_checked != ID_BlueInk ) {
6350|    i = m_PenBar.CommandToIndex( ID_BlueInk );
6351|    m_PenBar.SetButtonStyle( i, 0 );
6352|  }
6353|  if ( id_checked != ID_Marker ) {
6354|    i = m_PenBar.CommandToIndex( ID_Marker );
6355|    m_PenBar.SetButtonStyle( i, 0 );
6356|  }
6357|  if ( id_checked != ID_RedMarker ) {
6358|    i = m_PenBar.CommandToIndex( ID_RedMarker );
6359|    m_PenBar.SetButtonStyle( i, 0 );
6360|  }
6361|  if ( id_checked != ID_YellowMarker ) {
6362|    i = m_PenBar.CommandToIndex( ID_YellowMarker );
6363|    m_PenBar.SetButtonStyle( i, 0 );
6364|  }
6365|  if ( id_checked != ID_Rope ) {
6366|    i = m_PenBar.CommandToIndex( ID_Rope );
6367|    m_PenBar.SetButtonStyle( i, 0 );
6368|  }
6369|  if ( id_checked != ID_Eraser ) {
6370|    i = m_PenBar.CommandToIndex( ID_Eraser );
6371|    m_PenBar.SetButtonStyle( i, 0 );
6372|  }
6373|  #ifdef  USES_InkOverlay
6374|  if ( ! IsPenMode() ) {
6375|    HRESULT  hr;
6376|
6377|    if ( m_wndView->m_InkOverlay != NULL ) {
6378|
6379|      hr = m_wndView->m_InkOverlay->put_Enabled( VARIANT_FALSE );
6380|      if ( hr != 0 ) {
6381|        if ( hr != E_INK_COLLECTOR_BUSY ||  ! m_wndView->m_bDrag )
6382|          { CString  s;  s.Format("0x%X",hr);  MessageBox(s); error(); }
6383|      }
6384|      hr = m_wndView->m_InkOverlay->put_MousePointer( IMP_Default );
6385|      if ( hr != 0 )  error();
6386|    }
6387|  }
6388|  if ( m_mode != CMainFrame_UseRope ) {
6389|    HRESULT  hr;
6390|
6391|    if ( m_wndView->m_RopeTimer != 0 )  KillTimer( m_wndView->m_RopeTimer );
6392|    m_wndView->m_RopeTimer = 0;
6393|    m_wndView->m_RopeNPoint = -1;
6394|
6395|    if ( m_wndView->m_InkOverlay != NULL ) {
6396|      hr = m_wndView->m_InkOverlay->put_DynamicRendering( VARIANT_TRUE );
6397|      if ( hr != 0 )  error();
6398|    }
6399|  }
6400|  if ( ! bDisableResetSelect )
6401|    m_wndView->SelectInkToEmpty();
6402|  #endif
6403|
6404|  {
6405|    CPoint point;
6406|    POINT  pt;
6407|
6408|    GetCursorPos( &point );
6409|    m_wndView->ScreenToClient( &point );
6410|    pt = m_wndView->GetScrollPosition();
6411|    point += pt;
6412|    point -= m_wndView->m_MinusOffset;
6413|    point.x = point.x * 100 / m_wndView->m_Zoom;
6414|    point.y = point.y * 100 / m_wndView->m_Zoom;
6415|
6416|    m_wndView->SetCursorSVGCats( CPoint(point) );
6417|  }
6418|}
6419|
6420|
6421| 
6422|/***********************************************************************
6423|  14-2. <<< ツールバーやメニューの表示状態を調節する(有効無効、チェックのありなし) >>> 
6424|************************************************************************/
6425|
6426|void CMainFrame::OnUpdateSaveOv(CCmdUI* pCmdUI)
6427|{
6428|  pCmdUI->Enable( m_wndView->IsDirty() );
6429|}
6430|
6431|void CMainFrame::OnUpdateLowerPath(CCmdUI* pCmdUI)
6432|{
6433|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
6434|
6435|  pCmdUI->SetCheck( app->m_bLowerPath );
6436|}
6437|
6438|void CMainFrame::OnUpdateTaskTray(CCmdUI* pCmdUI)
6439|{
6440|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
6441|
6442|  pCmdUI->SetCheck( app->m_bTaskTray );
6443|}
6444|
6445|void CMainFrame::OnUpdateAutoSave(CCmdUI* pCmdUI)
6446|{
6447|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
6448|
6449|  pCmdUI->Enable( app->m_bTaskTray );
6450|  pCmdUI->SetCheck( app->m_bAutoSave );
6451|}
6452|
6453|void CMainFrame::OnUpdateUpdsk(CCmdUI* pCmdUI)
6454|{
6455|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
6456|
6457|  pCmdUI->Enable( app->m_bTaskTray );
6458|  pCmdUI->SetCheck( app->m_bUpdsk );
6459|}
6460|
6461|void CMainFrame::OnUpdateEditUndo(CCmdUI* pCmdUI)
6462|{
6463|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
6464|
6465|  pCmdUI->Enable( app->m_UndoBuf->IsAbleUndo() ||
6466|    ( m_wndView->m_BeforePrim != NULL && ! m_wndView->m_bDrag ) );
6467|}
6468|
6469|void CMainFrame::OnUpdateEditRedo(CCmdUI* pCmdUI)
6470|{
6471|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
6472|
6473|  pCmdUI->Enable( app->m_UndoBuf->IsAbleRedo() );
6474|}
6475|
6476|void CMainFrame::OnUpdateEditCut(CCmdUI* pCmdUI)
6477|{
6478|  OnUpdateDel( pCmdUI );
6479|}
6480|
6481|void CMainFrame::OnUpdateEditCopy(CCmdUI* pCmdUI)
6482|{
6483|  pCmdUI->Enable( m_wndView->GetSelectedStrokeCount() > 0 ||
6484|    m_wndView->m_HoldPrim != NULL || m_wndSplitter.GetActivePane() == m_Left );
6485|}
6486|
6487|void CMainFrame::OnUpdateEditPaste(CCmdUI* pCmdUI)
6488|{
6489|  pCmdUI->Enable( CanPaste(false) );
6490|}
6491|
6492|
6493|void CMainFrame::OnUpdateCopyStyle(CCmdUI* pCmdUI)
6494|{
6495|  OnUpdateEditCopy(pCmdUI);
6496|}
6497|
6498|void CMainFrame::OnUpdatePasteStyle(CCmdUI* pCmdUI)
6499|{
6500|  pCmdUI->Enable( ( m_wndView->GetSelectedStrokeCount() > 0 ||
6501|    m_wndView->m_HoldPrim != NULL ) && CanPaste(true) );
6502|}
6503|
6504|void CMainFrame::OnUpdateDel(CCmdUI* pCmdUI)
6505|{
6506|  if ( m_wndSplitter.GetActivePane() == m_Left ) {
6507|    OnUpdateDelPage(pCmdUI);
6508|  }
6509|  else {
6510|    pCmdUI->Enable( m_wndView->GetSelectedStrokeCount() > 0 ||
6511|      m_wndView->m_HoldPrim != NULL );
6512|  }
6513|}
6514|
6515|
6516|void CMainFrame::OnUpdateSingleClick(CCmdUI* pCmdUI)
6517|{
6518|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
6519|
6520|  pCmdUI->SetCheck( app->m_bSingleClick );
6521|}
6522|
6523|
6524|void CMainFrame::OnUpdateFindNext(CCmdUI* pCmdUI)
6525|{
6526|  pCmdUI->Enable( m_KWord != "" );
6527|}
6528|
6529|void CMainFrame::OnUpdateFindBack(CCmdUI* pCmdUI)
6530|{
6531|  pCmdUI->Enable( m_KWord != "" );
6532|}
6533|
6534|
6535|void CMainFrame::OnUpdateZBottom(CCmdUI* pCmdUI)
6536|{
6537|  pCmdUI->Enable( m_wndView->m_HoldPrim != NULL );
6538|}
6539|
6540|void CMainFrame::OnUpdateZDown(CCmdUI* pCmdUI)
6541|{
6542|  pCmdUI->Enable( m_wndView->m_HoldPrim != NULL );
6543|}
6544|
6545|void CMainFrame::OnUpdateZTop(CCmdUI* pCmdUI)
6546|{
6547|  pCmdUI->Enable( m_wndView->m_HoldPrim != NULL );
6548|}
6549|
6550|void CMainFrame::OnUpdateZUp(CCmdUI* pCmdUI)
6551|{
6552|  pCmdUI->Enable( m_wndView->m_HoldPrim != NULL );
6553|}
6554|
6555|void CMainFrame::OnUpdatePrimDown(CCmdUI* pCmdUI)
6556|{
6557|  pCmdUI->Enable( m_wndView->m_HoldPrim != NULL );
6558|}
6559|
6560|void CMainFrame::OnUpdatePrimLeft(CCmdUI* pCmdUI)
6561|{
6562|  pCmdUI->Enable( m_wndView->m_HoldPrim != NULL );
6563|}
6564|
6565|void CMainFrame::OnUpdatePrimRight(CCmdUI* pCmdUI)
6566|{
6567|  pCmdUI->Enable( m_wndView->m_HoldPrim != NULL );
6568|}
6569|
6570|void CMainFrame::OnUpdatePrimUp(CCmdUI* pCmdUI)
6571|{
6572|  pCmdUI->Enable( m_wndView->m_HoldPrim != NULL );
6573|}
6574|
6575|
6576|void CMainFrame::OnUpdateAlignHorizontal(CCmdUI* pCmdUI)
6577|{
6578|  pCmdUI->Enable( ListX_getN( &m_wndView->m_MultiHolds, ListX_ElemX ) >= 2 );
6579|}
6580|
6581|void CMainFrame::OnUpdateAlignVertical(CCmdUI* pCmdUI)
6582|{
6583|  pCmdUI->Enable( ListX_getN( &m_wndView->m_MultiHolds, ListX_ElemX ) >= 2 );
6584|}
6585|
6586|void CMainFrame::OnUpdateAlignLeft(CCmdUI* pCmdUI)
6587|{
6588|  pCmdUI->Enable( ListX_getN( &m_wndView->m_MultiHolds, ListX_ElemX ) >= 2 );
6589|}
6590|
6591|void CMainFrame::OnUpdateAlignRight(CCmdUI* pCmdUI)
6592|{
6593|  pCmdUI->Enable( ListX_getN( &m_wndView->m_MultiHolds, ListX_ElemX ) >= 2 );
6594|}
6595|
6596|void CMainFrame::OnUpdateAlignTop(CCmdUI* pCmdUI)
6597|{
6598|  pCmdUI->Enable( ListX_getN( &m_wndView->m_MultiHolds, ListX_ElemX ) >= 2 );
6599|}
6600|
6601|void CMainFrame::OnUpdateAlignBottom(CCmdUI* pCmdUI)
6602|{
6603|  pCmdUI->Enable( ListX_getN( &m_wndView->m_MultiHolds, ListX_ElemX ) >= 2 );
6604|}
6605|
6606|void CMainFrame::OnUpdateFitSizeHorizontal(CCmdUI* pCmdUI)
6607|{
6608|  pCmdUI->Enable( ListX_getN( &m_wndView->m_MultiHolds, ListX_ElemX ) >= 2 );
6609|}
6610|
6611|void CMainFrame::OnUpdateFitSizeVertical(CCmdUI* pCmdUI)
6612|{
6613|  pCmdUI->Enable( ListX_getN( &m_wndView->m_MultiHolds, ListX_ElemX ) >= 2 );
6614|}
6615|
6616|void CMainFrame::OnUpdateAlignIntervalHorizontal(CCmdUI* pCmdUI)
6617|{
6618|  pCmdUI->Enable( ListX_getN( &m_wndView->m_MultiHolds, ListX_ElemX ) >= 2 );
6619|}
6620|
6621|void CMainFrame::OnUpdateAlignIntervalVertical(CCmdUI* pCmdUI)
6622|{
6623|  pCmdUI->Enable( ListX_getN( &m_wndView->m_MultiHolds, ListX_ElemX ) >= 2 );
6624|}
6625|
6626|void CMainFrame::OnUpdateWindowColor(CCmdUI* pCmdUI)
6627|{
6628|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
6629|
6630|  pCmdUI->SetCheck( app->m_bBackTransparent );
6631|}
6632|
6633|void CMainFrame::OnUpdateViewPropBar(CCmdUI* pCmdUI)
6634|{
6635|  pCmdUI->SetCheck( m_PropBar.IsWindowVisible() );
6636|  m_PropBar.OnUpdate();
6637|}
6638|
6639|void CMainFrame::OnUpdateCreateBar(CCmdUI* pCmdUI)
6640|{
6641|  pCmdUI->SetCheck( m_CreateBar.IsWindowVisible() );
6642|}
6643|
6644|void CMainFrame::OnUpdateAlignBar(CCmdUI* pCmdUI)
6645|{
6646|  pCmdUI->SetCheck( m_AlignBar.IsWindowVisible() );
6647|}
6648|
6649|void CMainFrame::OnUpdatePenBar(CCmdUI* pCmdUI)
6650|{
6651|  pCmdUI->SetCheck( m_PenBar.IsWindowVisible() );
6652|}
6653|
6654|void CMainFrame::OnUpdateZoom100(CCmdUI* pCmdUI)
6655|{
6656|  pCmdUI->SetCheck( m_wndView->m_Zoom == 100 );
6657|}
6658|
6659|void CMainFrame::OnUpdateZoom200(CCmdUI* pCmdUI)
6660|{
6661|  pCmdUI->SetCheck( m_wndView->m_Zoom == 200 );
6662|}
6663|
6664|void CMainFrame::OnUpdateZoom400(CCmdUI* pCmdUI)
6665|{
6666|  pCmdUI->SetCheck( m_wndView->m_Zoom == 400 );
6667|}
6668|
6669|void CMainFrame::OnUpdateZoom800(CCmdUI* pCmdUI)
6670|{
6671|  pCmdUI->SetCheck( m_wndView->m_Zoom == 800 );
6672|}
6673|
6674|void CMainFrame::OnUpdateZoomWhole(CCmdUI* pCmdUI)
6675|{
6676|  pCmdUI->SetCheck( m_wndView->m_ZoomMode == CChildView_ZoomWhole );
6677|}
6678|
6679|void CMainFrame::OnUpdateZoomWidth(CCmdUI* pCmdUI)
6680|{
6681|  pCmdUI->SetCheck( m_wndView->m_ZoomMode == CChildView_ZoomWidth );
6682|}
6683|
6684|
6685|void CMainFrame::OnUpdateSideByTree(CCmdUI* pCmdUI)
6686|{
6687|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
6688|
6689|  pCmdUI->SetCheck( app->m_SplitMode != 1 );
6690|}
6691|
6692|void CMainFrame::OnUpdateMaxTree(CCmdUI* pCmdUI)
6693|{
6694|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
6695|
6696|  pCmdUI->Enable( ListX_getN( &app->m_file.m_pages, SVGCat_Page ) +
6697|    app->m_file.m_StartPageNum - 1 != 1 );
6698|}
6699|
6700|
6701|void CMainFrame::OnUpdateNextPage(CCmdUI* pCmdUI)
6702|{
6703|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
6704|  int  n = ListX_getN( &app->m_file.m_pages, SVGCat_Page );
6705|
6706|  pCmdUI->Enable( app->m_file.m_CurrentPageNum - app->m_file.m_StartPageNum < n - 1 &&
6707|    app->m_file.m_CurrentPageNum != 0 );
6708|}
6709|
6710|void CMainFrame::OnUpdatePrevPage(CCmdUI* pCmdUI)
6711|{
6712|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
6713|
6714|  pCmdUI->Enable( app->m_file.m_CurrentPageNum >= 2 );
6715|}
6716|
6717|void CMainFrame::OnUpdateFirstPage(CCmdUI* pCmdUI)
6718|{
6719|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
6720|
6721|  pCmdUI->Enable( ListX_getN( &app->m_file.m_pages, SVGCat_Page )
6722|    + app->m_file.m_StartPageNum - 1 >= 2  &&  app->m_file.m_CurrentPageNum != 0 );
6723|}
6724|
6725|void CMainFrame::OnUpdateLastPage(CCmdUI* pCmdUI)
6726|{
6727|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
6728|
6729|  pCmdUI->Enable( ListX_getN( &app->m_file.m_pages, SVGCat_Page )
6730|    + app->m_file.m_StartPageNum - 1  >= 2 &&  app->m_file.m_CurrentPageNum != 0 );
6731|}
6732|
6733|void CMainFrame::OnUpdateNewPage(CCmdUI* pCmdUI)
6734|{
6735|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
6736|
6737|  pCmdUI->Enable( app->m_file.m_CurrentPageNum != 0 );
6738|}
6739|
6740|void CMainFrame::OnUpdateNewChildPage(CCmdUI* pCmdUI)
6741|{
6742|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
6743|
6744|  pCmdUI->Enable( app->m_file.m_CurrentPageNum != 0 );
6745|}
6746|
6747|void CMainFrame::OnUpdateNewPrevPage(CCmdUI* pCmdUI)
6748|{
6749|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
6750|
6751|  pCmdUI->Enable( app->m_file.m_CurrentPageNum != 0 );
6752|}
6753|
6754|void CMainFrame::OnUpdateMakeBackPage(CCmdUI* pCmdUI)
6755|{
6756|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
6757|
6758|  pCmdUI->SetCheck( app->m_file.m_CurrentPageNum == 0 );
6759|}
6760|
6761|void CMainFrame::OnUpdateDelPage(CCmdUI* pCmdUI)
6762|{
6763|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
6764|  SVGCat_Page*  page = SVGCat_File_getCurrentPage( &app->m_file );
6765|
6766|  pCmdUI->Enable( page->next != NULL || page->prev != NULL || page->parent != NULL );
6767|}
6768|
6769|
6770|
6771|void CMainFrame::OnUpdateInk(CCmdUI* pCmdUI)
6772|{
6773|  pCmdUI->Enable( m_wndView->m_InkOverlay != NULL );
6774|}
6775|
6776|void CMainFrame::OnUpdateRedInk(CCmdUI* pCmdUI)
6777|{
6778|  pCmdUI->Enable( m_wndView->m_InkOverlay != NULL );
6779|}
6780|
6781|void CMainFrame::OnUpdateRedMarker(CCmdUI* pCmdUI)
6782|{
6783|  pCmdUI->Enable( m_wndView->m_InkOverlay != NULL );
6784|}
6785|
6786|void CMainFrame::OnUpdateBlueInk(CCmdUI* pCmdUI)
6787|{
6788|  pCmdUI->Enable( m_wndView->m_InkOverlay != NULL );
6789|}
6790|
6791|void CMainFrame::OnUpdateMarker(CCmdUI* pCmdUI)
6792|{
6793|  pCmdUI->Enable( m_wndView->m_InkOverlay != NULL );
6794|}
6795|
6796|void CMainFrame::OnUpdateYellowMarker(CCmdUI* pCmdUI)
6797|{
6798|  pCmdUI->Enable( m_wndView->m_InkOverlay != NULL );
6799|}
6800|
6801|void CMainFrame::OnUpdateRope(CCmdUI* pCmdUI)
6802|{
6803|  pCmdUI->Enable( m_wndView->m_InkOverlay != NULL );
6804|}
6805|
6806|void CMainFrame::OnUpdateEraser(CCmdUI* pCmdUI)
6807|{
6808|  pCmdUI->Enable( m_wndView->m_InkOverlay != NULL );
6809|}
6810|
6811|void CMainFrame::OnUpdateOpenLink(CCmdUI* pCmdUI)
6812|{
6813|  pCmdUI->Enable( GetLinkURL()[0] != '\0' );
6814|}
6815|
6816|
6817| 
6818|/*-------------------------------------------------------------------------*/
6819|/* 15. <<<< ◆プロパティ >>>>  */ 
6820|/*-------------------------------------------------------------------------*/
6821|
6822|
6823| 
6824|/***********************************************************************
6825|  15-1. <<< [CMainFrame::OnViewPropBar] プロパティ・バーの表示切替えを選んだときの処理 >>> 
6826|************************************************************************/
6827|void CMainFrame::OnViewPropBar()
6828|{
6829|  m_PropBar.SetVisible( ! m_PropBar.IsWindowVisible() );
6830|}
6831|
6832|
6833|void CMainFrame::OnViewMode()
6834|{
6835|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
6836|  CMenu*  sysMenu = GetSystemMenu(FALSE);
6837|
6838|  if ( m_bViewMode ) {
6839|    ShowToolBars();
6840|    app->m_SplitMode = m_SplitModeBeforeViewMode;
6841|    if ( m_SplitModeBeforeViewMode != 1 )
6842|      { app->m_SplitMode = 1;  OnSideByTree(); }
6843|    SetMenu( &m_MainMenu );
6844|    sysMenu->CheckMenuItem( ID_ViewMode, MF_UNCHECKED );
6845|    m_bViewMode = false;
6846|
6847|    if ( m_FileUpdateNotify != NULL )
6848|      FindCloseChangeNotification( m_FileUpdateNotify );
6849|  }
6850|  else {
6851|    if ( m_bScopeMode )  OnScopeMode();
6852|    m_bViewMode = true;
6853|    HideToolBars();
6854|    m_SplitModeBeforeViewMode = app->m_SplitMode;
6855|    NoTree();
6856|    SetMenu(NULL);
6857|    sysMenu->CheckMenuItem( ID_ViewMode, MF_CHECKED );
6858|
6859|    /* 開いているファイルが変更されたか監視する */
6860|    if ( app->m_path[0] != '\0' ) {
6861|      AfxBeginThread( CMainFrame_FileUpdateThread, this );
6862|    }
6863|  }
6864|}
6865|
6866|void CMainFrame::OnUpdateViewMode(CCmdUI* pCmdUI)
6867|{
6868|  pCmdUI->SetCheck( m_bViewMode );
6869|}
6870|
6871|void CMainFrame::OnScopeMode()
6872|{
6873|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
6874|  CMenu*  sysMenu = GetSystemMenu(FALSE);
6875|  WINDOWPLACEMENT  place;
6876|
6877|  #ifndef  SVGCats_ScopeMode
6878|  return;
6879|  #endif
6880|
6881|  if ( m_bScopeMode ) {
6882|    ShowWindow(SW_SHOW);
6883|    m_bScopeWindowZoomed = IsZoomed();
6884|    if ( ! m_bScopeWindowZoomed )  GetWindowRect( &m_ScopeWindowRect );
6885|    SetWindowPos( &wndBottom, m_OriginalWindowRect.left, m_OriginalWindowRect.top,
6886|      m_OriginalWindowRect.right - m_OriginalWindowRect.left,
6887|      m_OriginalWindowRect.bottom - m_OriginalWindowRect.top, SWP_SHOWWINDOW );
6888|    SetWindowPos( &wndTop, 0,0,0,0, SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOSIZE  );
6889|    if ( m_bOriginalWindowZoomed )
6890|      { GetWindowPlacement( &place );  place.showCmd = SW_SHOWMAXIMIZED;  SetWindowPlacement( &place ); }
6891|
6892|    ShowToolBars();
6893|    app->m_SplitMode = m_SplitModeBeforeViewMode;
6894|    if ( m_SplitModeBeforeViewMode != 1 )
6895|      { app->m_SplitMode = 1;  OnSideByTree(); }
6896|    SetMenu( &m_MainMenu );
6897|    sysMenu->CheckMenuItem( ID_ScopeMode, MF_UNCHECKED );
6898|    m_bScopeMode = false;
6899|
6900|    if ( m_FileUpdateNotify != NULL )
6901|      FindCloseChangeNotification( m_FileUpdateNotify );
6902|  }
6903|  else {
6904|    if ( m_bViewMode )  OnViewMode();
6905|
6906|    m_bOriginalWindowZoomed = IsZoomed();
6907|    if ( ! m_bOriginalWindowZoomed )  GetWindowRect( &m_OriginalWindowRect );
6908|    GetWindowPlacement( &place );  place.showCmd = SW_RESTORE;  SetWindowPlacement( &place );
6909|    SetWindowPos( &wndTopMost, m_ScopeWindowRect.left, m_ScopeWindowRect.top,
6910|      m_ScopeWindowRect.right - m_ScopeWindowRect.left,
6911|      m_ScopeWindowRect.bottom - m_ScopeWindowRect.top, SWP_SHOWWINDOW );
6912|    if ( m_bScopeWindowZoomed )
6913|      { GetWindowPlacement( &place );  place.showCmd = SW_SHOWMAXIMIZED;  SetWindowPlacement( &place ); }
6914|
6915|    m_bScopeHiding = false;
6916|    m_bScopeHidingCancel = false;
6917|    m_bScopeHide = false;
6918|    SetDefaultMode();
6919|    m_bActivated = true;
6920|    m_bMouseActivated = true;
6921|
6922|    HideToolBars();
6923|    m_SplitModeBeforeViewMode = app->m_SplitMode;
6924|    NoTree();
6925|    SetMenu(NULL);
6926|    sysMenu->CheckMenuItem( ID_ScopeMode, MF_CHECKED );
6927|    m_bScopeMode = true;
6928|
6929|    /* 開いているファイルが変更されたか監視する */
6930|    if ( app->m_path[0] != '\0' ) {
6931|      AfxBeginThread( CMainFrame_FileUpdateThread, this );
6932|    }
6933|  }
6934|}
6935|
6936|void CMainFrame::OnUpdateScopeMode(CCmdUI* pCmdUI)
6937|{
6938|  #ifndef  SVGCats_ScopeMode
6939|  MessageBox("デバッグメッセージ:スコープモードに関するシステムメニューとツールバーを、隠しリソースへ移動させてください。");
6940|  #endif
6941|  pCmdUI->SetCheck( m_bScopeMode );
6942|}
6943|
6944|UINT  CMainFrame_FileUpdateThread( LPVOID me )
6945|{
6946|  CMainFrame*  m = (CMainFrame*)me;
6947|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
6948|  time_t  newTime;
6949|
6950|  {
6951|    char  path[_MAX_PATH];
6952|
6953|    StrX_cpyFolder( path, app->m_path );
6954|    m->m_FileUpdateNotify = FindFirstChangeNotification(
6955|      path, FALSE,
6956|      FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_DIR_NAME |
6957|      FILE_NOTIFY_CHANGE_LAST_WRITE );
6958|  }
6959|
6960|  for (;;) {
6961|
6962|    /* ファイルの変更があるまで待機する */
6963|    FileX_getUpdate( app->m_path, &m->m_TimeStampOnTmpClose );
6964|    WaitForSingleObject( m->m_FileUpdateNotify, INFINITE );
6965|    Sleep(100);
6966|    if ( ! m->m_bViewMode )  break;
6967|    if ( ! FileX_isExist( app->m_path ) ) {
6968|      FindCloseChangeNotification( m->m_FileUpdateNotify );
6969|      break;
6970|    }
6971|    FileX_getUpdate( app->m_path, &newTime );
6972|    if ( newTime != m->m_TimeStampOnTmpClose ) {
6973|      m->PostMessage( WM_COMMAND, ID_Reload, 0 );
6974|    }
6975|
6976|    FindNextChangeNotification( m->m_FileUpdateNotify );
6977|  }
6978|  m->m_FileUpdateNotify = NULL;
6979|
6980|  return  0;
6981|}
6982|
6983|void CMainFrame::OnCreateBar()
6984|{
6985|  ShowControlBar( &m_CreateBar, ! m_CreateBar.IsWindowVisible(), FALSE );
6986|}
6987|
6988|void CMainFrame::OnAlignBar()
6989|{
6990|  ShowControlBar( &m_AlignBar, ! m_AlignBar.IsWindowVisible(), FALSE );
6991|}
6992|
6993|
6994|void CMainFrame::OnPenBar()
6995|{
6996|  ShowControlBar( &m_PenBar, ! m_PenBar.IsWindowVisible(), FALSE );
6997|}
6998|
6999|
7000| 
7001|/***********************************************************************
7002|  15-2. <<< [CMainFrame::OnDblClickProp] プロパティ・バーの項目をダブルクリックしたときの処理 >>> 
7003|************************************************************************/
7004|void  CMainFrame::OnDblClickProp()
7005|{
7006|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
7007|  CListBox*  list = (CListBox*)m_PropBar.GetDlgItem( IDC_Propertys );
7008|  int  i = list->GetCurSel();
7009|  char  name[256];
7010|  char  value[1024];
7011|  int*  range;
7012|  RECT  selRect;
7013|  int  type;
7014|  int  r;
7015|  void*  option;
7016|
7017|  list->GetItemRect( i, &selRect );
7018|  list->ClientToScreen( &selRect );
7019|
7020|  /* キャンパスのプロパティを変更する */
7021|  if ( m_PropPrim == NULL && m_PropStrokes == NULL ) {
7022|    if ( i < app->m_file.m_Canvas.GetNProp() ) {
7023|
7024|      type = app->m_file.m_Canvas.GetProp( i, app->m_bJapanese, name, sizeof(name),
7025|        value, sizeof(value), app->m_path, (void**)&range );
7026|
7027|      /* 整数値を入力する */
7028|      if ( type == CadPrim_Int ) {
7029|        if ( 0 && m_wndView->m_InkOverlay != NULL ) {
7030|          CInputIntDlg  dlg;
7031|
7032|          dlg.m_Msg = name;
7033|          dlg.m_Value = atoi( value );
7034|          dlg.m_Min = range[0];  dlg.m_Max = range[1];
7035|          dlg.m_PenInputPanel = m_wndView->m_PenInputPanel;
7036|        // dlg.m_bDispPenPanel = m_wndView->m_bInputML_bDispPenPanel;
7037|          dlg.m_bSetAtCursor = false;
7038|          dlg.m_XY.x = ( selRect.left + selRect.right ) / 2;
7039|          dlg.m_XY.y = ( selRect.top + selRect.bottom ) / 2;
7040|
7041|          r = dlg.DoModal();
7042|          sprintf( value, "%d", dlg.m_Value );
7043|        // m_wndView->m_bInputML_bDispPenPanel = dlg.m_bDispPenPanel;
7044|        }
7045|        else {
7046|          CInputIntDlg1  dlg;
7047|
7048|          app->m_file.m_Canvas.GetProp( i, app->m_bJapanese, name, sizeof(name),
7049|            value, sizeof(value), NULL, (void**)&range );
7050|
7051|          dlg.m_Msg = name;
7052|          dlg.m_Value = atoi( value );
7053|          dlg.m_Min = range[0];  dlg.m_Max = range[1];
7054|          dlg.m_PenInputPanel = m_wndView->m_PenInputPanel;
7055|        // dlg.m_bDispPenPanel = m_wndView->m_bInputML_bDispPenPanel;
7056|          dlg.m_bSetAtCursor = false;
7057|          dlg.m_XY.x = ( selRect.left + selRect.right ) / 2;
7058|          dlg.m_XY.y = ( selRect.top + selRect.bottom ) / 2;
7059|
7060|          r = dlg.DoModal();
7061|          sprintf( value, "%d", dlg.m_Value );
7062|        // m_wndView->m_bInputML_bDispPenPanel = dlg.m_bDispPenPanel;
7063|        }
7064|      }
7065|
7066|      /* ファイルパスを入力する */
7067|      else if ( type == CadPrim_Path ) {
7068|        if ( 0 && m_wndView->m_InkOverlay != NULL ) {
7069|          CInputDlg  dlg;
7070|
7071|          dlg.m_SelStart = 0;  dlg.m_SelEnd = -1;
7072|          dlg.m_Msg = name;  dlg.m_Text = value;
7073|          dlg.m_bPath = ( type != CadPrim_Text );
7074|          option = (void*)range;
7075|          if ( option != NULL )  dlg.m_Filter = (char*)option;
7076|          dlg.m_PenInputPanel = m_wndView->m_PenInputPanel;
7077|        // dlg.m_bDispPenPanel = m_wndView->m_bInputML_bDispPenPanel;
7078|          dlg.m_bSetAtCursor = false;
7079|          dlg.m_XY.x = ( selRect.left + selRect.right ) / 2;
7080|          dlg.m_XY.y = ( selRect.top + selRect.bottom ) / 2;
7081|          r = dlg.DoModal();
7082|          strcpy( value, dlg.m_Text );
7083|        // m_wndView->m_bInputML_bDispPenPanel = dlg.m_bDispPenPanel;
7084|        }
7085|         else {
7086|          CInputDlg1  dlg;
7087|
7088|          dlg.m_SelStart = 0;  dlg.m_SelEnd = -1;
7089|          dlg.m_Msg = name;  dlg.m_Text = value;
7090|          dlg.m_bPath = ( type != CadPrim_Text );
7091|          option = (void*)range;
7092|          if ( option != NULL )  dlg.m_Filter = (char*)option;
7093|          dlg.m_PenInputPanel = m_wndView->m_PenInputPanel;
7094|        // dlg.m_bDispPenPanel = m_wndView->m_bInputML_bDispPenPanel;
7095|          dlg.m_bSetAtCursor = false;
7096|          dlg.m_XY.x = ( selRect.left + selRect.right ) / 2;
7097|          dlg.m_XY.y = ( selRect.top + selRect.bottom ) / 2;
7098|          r = dlg.DoModal();
7099|          strcpy( value, dlg.m_Text );
7100|        // m_wndView->m_bInputML_bDispPenPanel = dlg.m_bDispPenPanel;
7101|        }
7102|      }
7103|      else  error();
7104|
7105|      /* プロパティの値を設定する */
7106|      if ( r == IDOK ) {
7107|
7108|        CadPrim*  before;
7109|        Canvas    can2;
7110|        SVGCat_Page*  page;
7111|        bool  bAllPage = false;
7112|        int  iPage;
7113|        int  iCurPage = app->m_file.m_CurrentPageNum - app->m_file.m_StartPageNum;
7114|        char  s[_MAX_PATH];
7115|
7116|        if ( app->m_file.m_CurrentPageNum == 0 ) {
7117|          bAllPage = ( MessageBox( "全てのページに設定しますか?", "", MB_YESNO ) == IDYES );
7118|        }
7119|
7120|        app->m_UndoBuf->StartMulti();
7121|
7122|        before = app->m_file.m_Canvas.GetNewCopy( &app->m_file.m_prims );
7123|        app->m_UndoBuf->AllocNewStep( before,
7124|          app->m_file.m_Canvas.GetNewCopy( &app->m_file.m_prims ), NULL, NULL,
7125|          app->m_file.m_CurrentPageNum - app->m_file.m_StartPageNum );
7126|
7127|        if ( bAllPage ) {
7128|          if ( type == CadPrim_Path ) {
7129|            strcpy( s, value );
7130|            if ( StrX_strchr2( value, '#' ) == NULL )
7131|              StrX_ins( StrX_refExt( s ) - 1, " (#)" );
7132|          }
7133|
7134|          iPage = 0;
7135|          for ( ListX_forEach( &app->m_file.m_pages, &page, SVGCat_Page ) ) {
7136|            can2 = page->canvas;
7137|            before = can2.GetNewCopy( &app->m_file.m_prims );
7138|
7139|            if ( type == CadPrim_Path ) {
7140|              strcpy( value, s );
7141|              if ( iPage != 0 || app->m_file.m_StartPageNum != 0 ) /* 背景ページ以外なら */
7142|                StrX_repSharp( value, sizeof(value), iPage + app->m_file.m_StartPageNum );
7143|            }
7144|
7145|            can2.SetProp( i, value, app->m_path );
7146|            if ( iPage == iCurPage )
7147|              app->m_file.m_Canvas.SetProp( i, value, app->m_path );
7148|
7149|            app->m_UndoBuf->AllocNewStep( before,
7150|              can2.GetNewCopy( &app->m_file.m_prims ), NULL, NULL,
7151|              iPage );
7152|            page->canvas = can2;
7153|            iPage++;
7154|          }
7155|        }
7156|        else
7157|          app->m_file.m_Canvas.SetProp( i, value, app->m_path );
7158|
7159|        app->m_UndoBuf->EndMulti();
7160|
7161|        m_wndView->m_bBitmap = FALSE;
7162|        m_wndView->SetScrollSize();
7163|        m_wndView->Invalidate(FALSE);
7164|        ResetProp();
7165|      }
7166|    }
7167|  }
7168|
7169|  /* 図形のプロパティを変更する */
7170|  else if ( ! ListX_isEmpty( &m_PropPrims ) && m_PropType != SVGCat_Ink_TypeID ) {
7171|    CString  s;
7172|    char  name[256];
7173|    char  value0[1024];
7174|    ListX  multiBefore;
7175|    ListX_ElemX*  p;
7176|    ListX_ElemX*  p2;
7177|    void*  dummy;
7178|
7179|    /* タイプを選択する */
7180|    if ( i == 0 && ( m_PropPrim != NULL || m_PropStrokes != NULL ) ) {
7181|      CInputSelectDlg  dlg;
7182|      ListX  list;
7183|      StrX_ListElem  strs[6];
7184|      int  iSel;
7185|      int  iSels[5];
7186|      int  types[5];
7187|      ListX_ElemX*  p;
7188|
7189|      ListX_init( &list );
7190|      dlg.m_Msg = ( app->m_bJapanese ? "タイプ" : "Type" );
7191|      iSel = 0;
7192|
7193|      for ( ListX_forEach( &app->m_file.m_prims, &p, ListX_ElemX ) ) {
7194|        if ( ((CadPrim*)p->p)->GetTypeID() == Text_Box_TypeID )  break;
7195|      }
7196|      if ( p != NULL ) {
7197|        ListX_addLast( &list, &strs[iSel] );
7198|        strs[iSel].p = ( app->m_bJapanese ? "テキスト" : "Text" );
7199|        iSels[0] = iSel;  types[iSel] = Text_Box_TypeID;  iSel++;
7200|      }
7201|
7202|      for ( ListX_forEach( &app->m_file.m_prims, &p, ListX_ElemX ) ) {
7203|        if ( ((CadPrim*)p->p)->GetTypeID() == Rect_Ex_TypeID )  break;
7204|      }
7205|      if ( p != NULL ) {
7206|        ListX_addLast( &list, &strs[iSel] );
7207|        strs[iSel].p = ( app->m_bJapanese ? "図形" : "Figure" );
7208|        iSels[1] = iSel;  types[iSel] = Rect_Ex_TypeID;  iSel++;
7209|      }
7210|
7211|      for ( ListX_forEach( &app->m_file.m_prims, &p, ListX_ElemX ) ) {
7212|        if ( ((CadPrim*)p->p)->GetTypeID() == Line_Ex_TypeID )  break;
7213|      }
7214|      if ( p != NULL ) {
7215|        ListX_addLast( &list, &strs[iSel] );
7216|        strs[iSel].p = ( app->m_bJapanese ? "ライン" : "Line" );
7217|        iSels[2] = iSel;  types[iSel] = Line_Ex_TypeID;  iSel++;
7218|      }
7219|
7220|      for ( ListX_forEach( &app->m_file.m_prims, &p, ListX_ElemX ) ) {
7221|        if ( ((CadPrim*)p->p)->GetTypeID() == Line_Corner_TypeID )  break;
7222|      }
7223|      if ( p != NULL ) {
7224|        ListX_addLast( &list, &strs[iSel] );
7225|        strs[iSel].p = ( app->m_bJapanese ? "折れ線" : "Cornered Line" );
7226|        iSels[3] = iSel;  types[iSel] = Line_Corner_TypeID;  iSel++;
7227|      }
7228|
7229|      for ( ListX_forEach( &app->m_file.m_prims, &p, ListX_ElemX ) ) {
7230|        if ( ((CadPrim*)p->p)->GetTypeID() == SVGCat_Ink_TypeID )  break;
7231|      }
7232|      if ( p != NULL ) {
7233|        ListX_addLast( &list, &strs[iSel] );
7234|        strs[iSel].p = ( app->m_bJapanese ? "インク" : "Ink" );
7235|        iSels[4] = iSel;  types[iSel] = SVGCat_Ink_TypeID;  iSel++;
7236|      }
7237|
7238|      switch ( m_PropType ) {
7239|        case Text_Box_TypeID: dlg.m_Value = iSels[0];  break;
7240|        case Rect_Ex_TypeID:  dlg.m_Value = iSels[1];  break;
7241|        case Line_Ex_TypeID:  dlg.m_Value = iSels[2];  break;
7242|        case Line_Corner_TypeID:  dlg.m_Value = iSels[3];  break;
7243|        case SVGCat_Ink_TypeID:   dlg.m_Value = iSels[4];  break;
7244|      }
7245|      dlg.m_Items = &list;
7246|      dlg.m_bSetAtCursor = false;
7247|      dlg.m_XY.x = ( selRect.left + selRect.right ) / 2;
7248|      dlg.m_XY.y = ( selRect.top + selRect.bottom ) / 2;
7249|      if ( dlg.DoModal() == IDOK ) {
7250|
7251|        m_PropType = types[dlg.m_Value];
7252|
7253|        m_wndView->Redraw( false );
7254|        SetPropMulti( &m_PropPrims, m_wndView->m_HoldStrokes, m_PropType );
7255|      }
7256|      return;
7257|    }
7258|
7259|    if ( m_PropType == -1 )  return;
7260|
7261|    i--;
7262|
7263|    /* アンドゥ情報を記録する */
7264|    ListX_init( &multiBefore );
7265|    for ( ListX_forEach( &m_PropPrims, &p, ListX_ElemX ) ) {
7266|      p2 = ListX_addLastMalloc( &multiBefore, ListX_ElemX );
7267|      p2->p = ((CadPrim*)p->p)->GetNewCopy( &app->m_file.m_prims );
7268|    }
7269|
7270|    /* プロパティの現在の値を取得する */
7271|    type = m_PropPrim->GetProp( i, app->m_bJapanese, name, sizeof(name), value0, sizeof(value0), app->m_path, &option );
7272|    for ( ListX_forEach( &m_PropPrims, &p, ListX_ElemX ) ) {
7273|      if ( ((CadPrim*)p->p)->GetTypeID() != m_PropType )  continue;
7274|      ((CadPrim*)p->p)->GetProp( i, app->m_bJapanese, name, sizeof(name), value, sizeof(value), app->m_path, &dummy );
7275|      if ( strcmp( value, value0 ) != 0 )  break;
7276|    }
7277|    if ( p != NULL ) {
7278|      value[0] = '\0';
7279|    }
7280|
7281|    switch ( type ) {
7282|
7283|     /* テキスト入力する */
7284|     case  CadPrim_Text:
7285|     case  CadPrim_Path:
7286|     case  CadPrim_PathMust:
7287|     if ( 0 && m_wndView->m_InkOverlay != NULL ) {
7288|      CInputDlg  dlg;
7289|
7290|      dlg.m_SelStart = 0;  dlg.m_SelEnd = -1;
7291|      dlg.m_Msg = name;  dlg.m_Text = value;
7292|      dlg.m_bPath = ( type != CadPrim_Text );
7293|      if ( option != NULL )  dlg.m_Filter = (char*)option;
7294|      dlg.m_PenInputPanel = m_wndView->m_PenInputPanel;
7295|//      dlg.m_bDispPenPanel = m_wndView->m_bInputML_bDispPenPanel;
7296|      dlg.m_bSetAtCursor = false;
7297|      dlg.m_XY.x = ( selRect.left + selRect.right ) / 2;
7298|      dlg.m_XY.y = ( selRect.top + selRect.bottom ) / 2;
7299|      if ( dlg.DoModal() == IDOK ) {
7300|        for ( ListX_forEach( &m_PropPrims, &p, ListX_ElemX ) ) {
7301|          if ( ((CadPrim*)p->p)->GetTypeID() != m_PropType )  continue;
7302|          ((CadPrim*)p->p)->SetProp( i, dlg.m_Text, app->m_path );
7303|        }
7304|        m_wndView->Redraw( false );
7305|        SetPropMulti( &m_PropPrims, m_wndView->m_HoldStrokes, m_PropType );
7306|      }
7307|//      m_wndView->m_bInputML_bDispPenPanel = dlg.m_bDispPenPanel;
7308|     }
7309|     else {
7310|      CInputDlg1  dlg;
7311|
7312|      dlg.m_SelStart = 0;  dlg.m_SelEnd = -1;
7313|      dlg.m_Msg = name;  dlg.m_Text = value;
7314|      dlg.m_bPath = ( type != CadPrim_Text );
7315|      if ( option != NULL )  dlg.m_Filter = (char*)option;
7316|      dlg.m_PenInputPanel = m_wndView->m_PenInputPanel;
7317|//      dlg.m_bDispPenPanel = m_wndView->m_bInputML_bDispPenPanel;
7318|      dlg.m_bSetAtCursor = false;
7319|      dlg.m_XY.x = ( selRect.left + selRect.right ) / 2;
7320|      dlg.m_XY.y = ( selRect.top + selRect.bottom ) / 2;
7321|      if ( dlg.DoModal() == IDOK ) {
7322|        for ( ListX_forEach( &m_PropPrims, &p, ListX_ElemX ) ) {
7323|          if ( ((CadPrim*)p->p)->GetTypeID() != m_PropType )  continue;
7324|          ((CadPrim*)p->p)->SetProp( i, dlg.m_Text, app->m_path );
7325|        }
7326|        m_wndView->Redraw( false );
7327|        SetPropMulti( &m_PropPrims, m_wndView->m_HoldStrokes, m_PropType );
7328|      }
7329|//      m_wndView->m_bInputML_bDispPenPanel = dlg.m_bDispPenPanel;
7330|     }
7331|      break;
7332|
7333|
7334|     /* 複数行のテキスト入力する */
7335|     case  CadPrim_TextML: {
7336|     if ( 0 && m_wndView->m_InkOverlay != NULL ) {
7337|      CInputML  dlg;
7338|
7339|      dlg.m_ID = (void*)m_PropPrim->GetID();
7340|      dlg.m_Text = value;
7341|      dlg.m_PenInputPanel = m_wndView->m_PenInputPanel;
7342|      dlg.m_bDispPenPanel = m_wndView->m_bInputML_bDispPenPanel;
7343|      dlg.m_CursorPos.x = ( selRect.left + selRect.right ) / 2;
7344|      dlg.m_CursorPos.y = ( selRect.top + selRect.bottom ) / 2;
7345|      dlg.m_SaveObj = this;  dlg.m_SaveFunc = (CInputML_SaveF)CChildView_saveOnEditing;
7346|      dlg.m_bCtrlRet = app->m_bCtrlRet;
7347|      dlg.m_bJapanese = app->m_bJapanese;
7348|      dlg.m_bHideMain = app->m_bHideMain;
7349|      dlg.m_HideTarget = this;
7350|      dlg.m_ShowWindowFunc = (CInputML_ShowWindowF)CMainFrame_ShowWindowFunc;
7351|      dlg.m_kword = m_KWord;
7352|      m_wndView->m_InputML = &dlg;
7353|      dlg.DoModal();
7354|      m_wndView->m_InputML = NULL;
7355|      app->m_bHideMain = dlg.m_bHideMain;
7356|      for ( ListX_forEach( &m_PropPrims, &p, ListX_ElemX ) ) {
7357|        if ( ((CadPrim*)p->p)->GetTypeID() != m_PropType )  continue;
7358|        ((CadPrim*)p->p)->SetProp( i, dlg.m_Text, app->m_path );
7359|      }
7360|      m_wndView->Redraw( false );
7361|      SetPropMulti( &m_PropPrims, m_wndView->m_HoldStrokes, m_PropType );
7362|      m_wndView->m_bInputML_bDispPenPanel = dlg.m_bDispPenPanel;
7363|      app->m_bHideMain = dlg.m_bHideMain;
7364|      m_KWord = dlg.m_kword;
7365|     }
7366|     else {
7367|      CInputML1  dlg;
7368|
7369|      dlg.m_ID = (void*)m_PropPrim->GetID();
7370|      dlg.m_Text = value;
7371|      dlg.m_PenInputPanel = m_wndView->m_PenInputPanel;
7372|      dlg.m_bDispPenPanel = m_wndView->m_bInputML_bDispPenPanel;
7373|      dlg.m_CursorPos.x = ( selRect.left + selRect.right ) / 2;
7374|      dlg.m_CursorPos.y = ( selRect.top + selRect.bottom ) / 2;
7375|      dlg.m_SaveObj = this;  dlg.m_SaveFunc = (CInputML1_SaveF)CChildView_saveOnEditing1;
7376|      dlg.m_bCtrlRet = app->m_bCtrlRet;
7377|      dlg.m_bJapanese = app->m_bJapanese;
7378|      dlg.m_bHideMain = app->m_bHideMain;
7379|      dlg.m_HideTarget = this;
7380|      dlg.m_ShowWindowFunc = (CInputML1_ShowWindowF)CMainFrame_ShowWindowFunc;
7381|      dlg.m_kword = m_KWord;
7382|      m_wndView->m_InputML1 = &dlg;
7383|      dlg.DoModal();
7384|      m_wndView->m_InputML1 = NULL;
7385|      app->m_bHideMain = dlg.m_bHideMain;
7386|      for ( ListX_forEach( &m_PropPrims, &p, ListX_ElemX ) ) {
7387|        if ( ((CadPrim*)p->p)->GetTypeID() != m_PropType )  continue;
7388|        ((CadPrim*)p->p)->SetProp( i, dlg.m_Text, app->m_path );
7389|      }
7390|      m_wndView->Redraw( false );
7391|      SetPropMulti( &m_PropPrims, m_wndView->m_HoldStrokes, m_PropType );
7392|      m_wndView->m_bInputML_bDispPenPanel = dlg.m_bDispPenPanel;
7393|      app->m_bHideMain = dlg.m_bHideMain;
7394|      m_KWord = dlg.m_kword;
7395|     }
7396|      break;
7397|     }
7398|
7399|     /* 色の選択ダイアログボックスから入力する */
7400|     case  CadPrim_Color: {
7401|      CColorDialog  dlg( StrX_getColorValue( value ), CC_FULLOPEN, this );
7402|
7403|      if ( dlg.DoModal() == IDOK ) {
7404|
7405|        StrX_getColorStr( value, dlg.GetColor() );
7406|        for ( ListX_forEach( &m_PropPrims, &p, ListX_ElemX ) ) {
7407|          if ( ((CadPrim*)p->p)->GetTypeID() != m_PropType )  continue;
7408|          ((CadPrim*)p->p)->SetProp( i, value, app->m_path );
7409|        }
7410|
7411|        m_wndView->Redraw( false );
7412|        SetPropMulti( &m_PropPrims, m_wndView->m_HoldStrokes, m_PropType );
7413|      }
7414|      break;
7415|     }
7416|
7417|     /* フォントダイアログボックスから入力する */
7418|     case  CadPrim_Font: {
7419|      CFont  font;
7420|      CClientDC  dc( this );
7421|      LOGFONT  logFont;
7422|      int   size10;
7423|      bool  bBold,  bItalic;
7424|
7425|      StrX_getFontValue( value, name, &size10, &bBold, &bItalic );
7426|      font.CreatePointFont( size10, name, &dc );
7427|      font.GetLogFont( &logFont );
7428|      logFont.lfWeight = bBold ? FW_BOLD : FW_NORMAL;
7429|      logFont.lfItalic = bItalic;
7430|
7431|      CFontDialog  dlg( &logFont, CF_SCREENFONTS, NULL, this );
7432|
7433|      if ( dlg.DoModal() == IDOK ) {
7434|
7435|        StrX_getFontStr( value, dlg.GetFaceName(), dlg.GetSize(),
7436|          dlg.IsBold() != 0, dlg.IsItalic() != 0 );
7437|        for ( ListX_forEach( &m_PropPrims, &p, ListX_ElemX ) ) {
7438|          if ( ((CadPrim*)p->p)->GetTypeID() != m_PropType )  continue;
7439|          ((CadPrim*)p->p)->SetProp( i, value, app->m_path );
7440|        }
7441|
7442|        m_wndView->Redraw( false );
7443|        SetPropMulti( &m_PropPrims, m_wndView->m_HoldStrokes, m_PropType );
7444|      }
7445|      break;
7446|     }
7447|
7448|     /* ブール値をトグルする */
7449|     case  CadPrim_Bool: {
7450|
7451|      for ( ListX_forEach( &m_PropPrims, &p, ListX_ElemX ) ) {
7452|        if ( ((CadPrim*)p->p)->GetTypeID() != m_PropType )  continue;
7453|        ((CadPrim*)p->p)->SetProp( i, ( value[0] == '0' ? "1" : "0" ), app->m_path );
7454|      }
7455|
7456|      m_wndView->Redraw( false );
7457|      SetPropMulti( &m_PropPrims, m_wndView->m_HoldStrokes, m_PropType );
7458|      break;
7459|     }
7460|
7461|     /* 整数を入力する */
7462|     case  CadPrim_Int:
7463|     if ( 0 && m_wndView->m_InkOverlay != NULL ) {
7464|      CInputIntDlg  dlg;
7465|
7466|      dlg.m_Msg = name;  dlg.m_Value = atoi( value );
7467|      dlg.m_Min = ((int*)option)[0];  dlg.m_Max = ((int*)option)[1];
7468|      dlg.m_PenInputPanel = m_wndView->m_PenInputPanel;
7469|//      dlg.m_bDispPenPanel = m_wndView->m_bInputML_bDispPenPanel;
7470|      dlg.m_bSetAtCursor = false;
7471|      dlg.m_XY.x = ( selRect.left + selRect.right ) / 2;
7472|      dlg.m_XY.y = ( selRect.top + selRect.bottom ) / 2;
7473|      if ( dlg.DoModal() == IDOK ) {
7474|        char  s[12];
7475|        int  value = dlg.m_Value;
7476|        if ( value < ((int*)option)[0] )  value = ((int*)option)[0];
7477|        if ( value > ((int*)option)[1] )  value = ((int*)option)[1];
7478|
7479|        for ( ListX_forEach( &m_PropPrims, &p, ListX_ElemX ) ) {
7480|          if ( ((CadPrim*)p->p)->GetTypeID() != m_PropType )  continue;
7481|          sprintf( s, "%d", value );
7482|          ((CadPrim*)p->p)->SetProp( i, s, app->m_path );
7483|        }
7484|
7485|        m_wndView->Redraw( false );
7486|        SetPropMulti( &m_PropPrims, m_wndView->m_HoldStrokes, m_PropType );
7487|      }
7488|//      m_wndView->m_bInputML_bDispPenPanel = dlg.m_bDispPenPanel;
7489|     }
7490|     else {
7491|      CInputIntDlg1  dlg;
7492|
7493|      dlg.m_Msg = name;  dlg.m_Value = atoi( value );
7494|      dlg.m_Min = ((int*)option)[0];  dlg.m_Max = ((int*)option)[1];
7495|      dlg.m_PenInputPanel = m_wndView->m_PenInputPanel;
7496|//      dlg.m_bDispPenPanel = m_wndView->m_bInputML_bDispPenPanel;
7497|      dlg.m_bSetAtCursor = false;
7498|      dlg.m_XY.x = ( selRect.left + selRect.right ) / 2;
7499|      dlg.m_XY.y = ( selRect.top + selRect.bottom ) / 2;
7500|      if ( dlg.DoModal() == IDOK ) {
7501|        char  s[12];
7502|        int  value = dlg.m_Value;
7503|        if ( value < ((int*)option)[0] )  value = ((int*)option)[0];
7504|        if ( value > ((int*)option)[1] )  value = ((int*)option)[1];
7505|
7506|        for ( ListX_forEach( &m_PropPrims, &p, ListX_ElemX ) ) {
7507|          if ( ((CadPrim*)p->p)->GetTypeID() != m_PropType )  continue;
7508|          sprintf( s, "%d", value );
7509|          ((CadPrim*)p->p)->SetProp( i, s, app->m_path );
7510|        }
7511|
7512|        m_wndView->Redraw( false );
7513|        SetPropMulti( &m_PropPrims, m_wndView->m_HoldStrokes, m_PropType );
7514|      }
7515|//      m_wndView->m_bInputML_bDispPenPanel = dlg.m_bDispPenPanel;
7516|     }
7517|      break;
7518|
7519|
7520|     /* 選択する */
7521|     case  CadPrim_Select: {
7522|      CInputSelectDlg  dlg;
7523|
7524|      dlg.m_Msg = name;  dlg.m_Value = atoi( value );
7525|      dlg.m_Items = (ListX*)option;
7526|      dlg.m_bSetAtCursor = false;
7527|      dlg.m_XY.x = ( selRect.left + selRect.right ) / 2;
7528|      dlg.m_XY.y = ( selRect.top + selRect.bottom ) / 2;
7529|      if ( dlg.DoModal() == IDOK ) {
7530|        char  s[12];
7531|
7532|        for ( ListX_forEach( &m_PropPrims, &p, ListX_ElemX ) ) {
7533|          if ( ((CadPrim*)p->p)->GetTypeID() != m_PropType )  continue;
7534|          sprintf( s, "%d", dlg.m_Value );
7535|          ((CadPrim*)p->p)->SetProp( i, s, app->m_path );
7536|        }
7537|
7538|        m_wndView->Redraw( false );
7539|        SetPropMulti( &m_PropPrims, m_wndView->m_HoldStrokes, m_PropType );
7540|      }
7541|      break;
7542|     }
7543|
7544|#if MAINFRM_OLD_030108
7545|     /* ファイルを選択する */
7546|     case  CadPrim_Path:
7547|     case  CadPrim_PathMust: {
7548|      if ( app->m_path[0] != '\0' ) {
7549|        StrX_toAbsPath2( value, sizeof(value), app->m_path );
7550|      }
7551|
7552|      CFileDialog  dlg( TRUE, NULL, value, OFN_HIDEREADONLY | OFN_EXPLORER, (char*)option );
7553|
7554|      #ifdef  NDEBUG
7555|        dlg.m_ofn.Flags &= ~OFN_ENABLEHOOK;  /* Win2000以降の新しいファイルダイアログにする */
7556|      #endif
7557|
7558|      if ( strstr( (char*)option, "png" ) != NULL )
7559|        dlg.m_ofn.lpstrInitialDir = app->m_ImgFolderPath;
7560|
7561|      if ( dlg.DoModal() == IDOK ) {
7562|
7563|        for ( ListX_forEach( &m_PropPrims, &p, ListX_ElemX ) ) {
7564|          if ( ((CadPrim*)p->p)->GetTypeID() != m_PropType )  continue;
7565|          ((CadPrim*)p->p)->SetProp( i, dlg.GetPathName(), app->m_path );
7566|        }
7567|
7568|        m_wndView->Redraw( false );
7569|        SetPropMulti( &m_PropPrims, m_PropType );
7570|      }
7571|      else {
7572|        if ( type == CadPrim_Path && value[0] != '\0' ) {
7573|          CString  msg1;
7574|
7575|          if ( app->m_bJapanese ) {
7576|            msg1.LoadString( IDS_DeleteValue );
7577|            msg1 = CString( name ) + msg1;
7578|          }
7579|          else {
7580|            msg1.LoadString( IDS_DeleteValue_E );
7581|            msg1 = msg1 + name + " ?";
7582|          }
7583|
7584|          if ( MessageBox( msg1, NULL, MB_YESNO | MB_DEFBUTTON2 ) == IDYES ) {
7585|            for ( ListX_forEach( &m_PropPrims, &p, ListX_ElemX ) ) {
7586|              ((CadPrim*)p->p)->SetProp( i, "", app->m_path );
7587|            }
7588|            m_wndView->Redraw( false );
7589|            SetPropMulti( &m_PropPrims, m_PropType );
7590|          }
7591|        }
7592|      }
7593|
7594|      break;
7595|     }
7596|#endif
7597|    }
7598|
7599|    /* アンドゥ情報を記録する */
7600|    app->m_UndoBuf->StartMulti();
7601|    p2 = ListX_getFirst( &multiBefore, ListX_ElemX );
7602|    for ( ListX_forEach( &m_PropPrims, &p, ListX_ElemX ) ) {
7603|      app->m_UndoBuf->AllocNewStep( (CadPrim*)p2->p,
7604|        ((CadPrim*)p->p)->GetNewCopy( &app->m_file.m_prims ), NULL, NULL,
7605|        app->m_file.m_CurrentPageNum - app->m_file.m_StartPageNum );
7606|      p2 = ListX_Elem_getNextT( p2, ListX_ElemX );
7607|    }
7608|    app->m_UndoBuf->EndMulti();
7609|
7610|    ListX_toEmptyDelete( &multiBefore, ListX_ElemX, NULL );
7611|  }
7612|
7613|
7614|  /* インクのプロパティを表示する */
7615|  else if ( m_PropStrokes != NULL ) {
7616|    long  iStroke, nStroke;
7617|    IInkStrokeDisp*  stroke;
7618|    IInkDrawingAttributes*  attr;
7619|    Undo_InkAttr*  before;
7620|    HRESULT  hr;
7621|
7622|    hr = m_PropStrokes->get_Count( &nStroke );  if ( hr != 0 )  error();
7623|
7624|    before = Undo_InkAttr_new( m_PropStrokes );
7625|    i--;
7626|
7627|    /* 色 */
7628|    if ( i == 0 ) {
7629|      CColorDialog  dlg( StrX_getColorValue( value ), CC_FULLOPEN, this );
7630|
7631|      if ( dlg.DoModal() == IDOK ) {
7632|
7633|        for ( iStroke = 0; iStroke < nStroke; iStroke++ ) {
7634|          hr = m_PropStrokes->Item( iStroke, &stroke );  if ( hr != 0 )  error();
7635|          hr = stroke->get_DrawingAttributes( &attr );  if ( hr != 0 )  error();
7636|          hr = attr->put_Color( dlg.GetColor() );  if ( hr != 0 )  error();
7637|          hr = attr->Release();  attr = NULL;
7638|          hr = stroke->Release();  stroke = NULL;
7639|        }
7640|      }
7641|    }
7642|
7643|
7644|    /* 幅 */
7645|    if ( i == 1 ) {
7646|      float  fvalue;
7647|      enum { min = 10, max = 9999 };
7648|
7649|      hr = m_PropStrokes->Item( 0, &stroke );  if ( hr != 0 )  error();
7650|      hr = stroke->get_DrawingAttributes( &attr );  if ( hr != 0 )  error();
7651|      hr = attr->get_Width( &fvalue );  if ( hr != 0 )  error();
7652|      hr = attr->Release();  attr = NULL;
7653|      hr = stroke->Release();  stroke = NULL;
7654|
7655|     if ( m_wndView->m_InkOverlay != NULL ) {
7656|      CInputIntDlg  dlg;
7657|
7658|      dlg.m_Msg = app->m_bJapanese ? "幅" : "Width";
7659|      dlg.m_Value = (int)fvalue;
7660|      dlg.m_Min = min;  dlg.m_Max = max;
7661|      dlg.m_PenInputPanel = m_wndView->m_PenInputPanel;
7662|//      dlg.m_bDispPenPanel = m_wndView->m_bInputML_bDispPenPanel;
7663|      dlg.m_bSetAtCursor = false;
7664|      dlg.m_XY.x = ( selRect.left + selRect.right ) / 2;
7665|      dlg.m_XY.y = ( selRect.top + selRect.bottom ) / 2;
7666|      if ( dlg.DoModal() == IDOK ) {
7667|        int  value = dlg.m_Value;
7668|        if ( value < min )  value = min;
7669|        if ( value > max )  value = max;
7670|
7671|        for ( iStroke = 0; iStroke < nStroke; iStroke++ ) {
7672|          hr = m_PropStrokes->Item( iStroke, &stroke );  if ( hr != 0 )  error();
7673|          hr = stroke->get_DrawingAttributes( &attr );  if ( hr != 0 )  error();
7674|          hr = attr->put_Width( (float)value );  if ( hr != 0 )  error();
7675|          hr = attr->Release();  attr = NULL;
7676|          hr = stroke->Release();  stroke = NULL;
7677|        }
7678|      }
7679|//      m_wndView->m_bInputML_bDispPenPanel = dlg.m_bDispPenPanel;
7680|     }
7681|     else {
7682|      CInputIntDlg1  dlg;
7683|
7684|      dlg.m_Msg = app->m_bJapanese ? "幅" : "Width";
7685|      dlg.m_Value = (int)fvalue;
7686|      dlg.m_Min = min;  dlg.m_Max = max;
7687|      dlg.m_PenInputPanel = m_wndView->m_PenInputPanel;
7688|//      dlg.m_bDispPenPanel = m_wndView->m_bInputML_bDispPenPanel;
7689|      dlg.m_bSetAtCursor = false;
7690|      dlg.m_XY.x = ( selRect.left + selRect.right ) / 2;
7691|      dlg.m_XY.y = ( selRect.top + selRect.bottom ) / 2;
7692|      if ( dlg.DoModal() == IDOK ) {
7693|        int  value = dlg.m_Value;
7694|        if ( value < min )  value = min;
7695|        if ( value > max )  value = max;
7696|
7697|        for ( iStroke = 0; iStroke < nStroke; iStroke++ ) {
7698|          hr = m_PropStrokes->Item( iStroke, &stroke );  if ( hr != 0 )  error();
7699|          hr = stroke->get_DrawingAttributes( &attr );  if ( hr != 0 )  error();
7700|          hr = attr->put_Width( (float)value );  if ( hr != 0 )  error();
7701|          hr = attr->Release();  attr = NULL;
7702|          hr = stroke->Release();  stroke = NULL;
7703|        }
7704|      }
7705|//      m_wndView->m_bInputML_bDispPenPanel = dlg.m_bDispPenPanel;
7706|     }
7707|    }
7708|
7709|    /* 筆圧 */
7710|    if ( i == 2 ) {
7711|      VARIANT_BOOL  value_b;
7712|
7713|      hr = m_PropStrokes->Item( 0, &stroke );  if ( hr != 0 )  error();
7714|      hr = stroke->get_DrawingAttributes( &attr );  if ( hr != 0 )  error();
7715|      hr = attr->get_IgnorePressure( &value_b );  if ( hr != 0 )  error();
7716|      hr = attr->Release();  attr = NULL;
7717|      hr = stroke->Release();  stroke = NULL;
7718|
7719|      if ( m_wndView->m_InkOverlay != NULL ) {
7720|        value_b = ! value_b;
7721|        for ( iStroke = 0; iStroke < nStroke; iStroke++ ) {
7722|          hr = m_PropStrokes->Item( iStroke, &stroke );  if ( hr != 0 )  error();
7723|          hr = stroke->get_DrawingAttributes( &attr );  if ( hr != 0 )  error();
7724|          hr = attr->put_IgnorePressure( value_b );  if ( hr != 0 )  error();
7725|          hr = attr->Release();  attr = NULL;
7726|          hr = stroke->Release();  stroke = NULL;
7727|        }
7728|      }
7729|    }
7730|
7731|    app->m_UndoBuf->AllocNewStep_Ink3( Undo_Ink_ChgAttr, m_PropStrokes,
7732|      before, Undo_InkAttr_new( m_PropStrokes ),  app->m_file.m_CurrentPageNum - app->m_file.m_StartPageNum );
7733|
7734|    m_wndView->Redraw( false );
7735|    SetPropMulti( &m_PropPrims, m_wndView->m_HoldStrokes, m_PropType );
7736|  }
7737|}
7738|
7739|
7740| 
7741|/***********************************************************************
7742|  15-3. <<< [CMainFrame::OnSetFocusProp] シングルクリックでプロパティを編集する >>> 
7743|【補足】
7744|・CListBox で、クリックを検出する WM_LBUTTONUP が使えないので、
7745|  SetFocus で代用した。
7746|************************************************************************/
7747|void  CMainFrame::OnSetFocusProp()
7748|{
7749|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
7750|  CListBox*  list = (CListBox*)m_PropBar.GetDlgItem( IDC_Propertys );
7751|
7752|  if ( app->m_bSingleClick && ! m_DisableOnSetFocusProp ) {
7753|    BOOL  bOutSide;
7754|    CPoint pt;
7755|    UINT  idx;
7756|
7757|    GetCursorPos( &pt );
7758|    list->ScreenToClient( &pt );
7759|    idx = list->ItemFromPoint( pt, bOutSide );
7760|    list->SetCurSel( idx );
7761|    OnDblClickProp();
7762|    list->SetCurSel( idx );
7763|    SetFocus();  /* LostFocus */
7764|  }
7765|}
7766|
7767|
7768| 
7769|/***********************************************************************
7770|  15-4. <<< [CMainFrame::ResetProp] プロパティ・バーの表示をキャンバスのものに戻す >>> 
7771|************************************************************************/
7772|void  CMainFrame::ResetProp()
7773|{
7774|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
7775|  CListBox*  list = (CListBox*)m_PropBar.GetDlgItem( IDC_Propertys );
7776|  int   i;
7777|  char  name[256];
7778|  char  value[256];
7779|  char  s[512];
7780|  int*  range;
7781|
7782|  list->ResetContent();
7783|
7784|  for ( i = 0; i < app->m_file.m_Canvas.GetNProp(); i++ ) {
7785|    app->m_file.m_Canvas.GetProp( i, app->m_bJapanese, name, sizeof(name),
7786|      value, sizeof(value), app->m_path, (void**)&range );
7787|    sprintf( s, "%s = %s", name, value );
7788|    list->AddString( s );
7789|  }
7790|
7791|  #ifndef  NDEBUG
7792|  {
7793|    sprintf( name, "Errors_X = %d", Errors_X );
7794|    list->AddString( name );
7795|    sprintf( name, "Errors_X2 = %d", Errors_X2 );
7796|    list->AddString( name );
7797|    sprintf( name, "Errors_X3 = %d", Errors_X3 );
7798|    list->AddString( name );
7799|  }
7800|  #endif
7801|
7802|  m_PropPrim = NULL;
7803|  ListX_toEmptyDelete( &m_PropPrims, ListX_ElemX, NULL );
7804|  m_PropStrokes = NULL;
7805|  m_PropType = -1;
7806|}
7807|
7808|
7809| 
7810|/***********************************************************************
7811|  15-5. <<< [CMainFrame::SetPropMulti] プロパティ・バーの表示を更新する >>> 
7812|【引数】
7813|  ・ListX*  prims;  プロパティを表示する図形の集合(NULL=プロパティの値の更新)
7814|************************************************************************/
7815|void  CMainFrame::SetPropMulti( ListX* prims, IInkStrokes* strokes, int type )
7816|{
7817|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
7818|  CListBox*  list = (CListBox*)m_PropBar.GetDlgItem( IDC_Propertys );
7819|  char*  s;
7820|  int  i, n;
7821|  CadPrim*  first;
7822|  ListX_ElemX*  p;
7823|  ListX_ElemX*  p2;
7824|  char  name[256];
7825|  char  value[1024];
7826|  char  value0[1024];
7827|  void*  option;
7828|  void*  dummy;
7829|  long  nStroke;
7830|  HRESULT  hr;
7831|
7832|  m_PropType = type;
7833|
7834|  if ( strokes == NULL )  nStroke = 0;
7835|  else {  hr = strokes->get_Count( &nStroke );  if ( hr != NULL )  error(); }
7836|
7837|  p = ListX_getFirst( prims, ListX_ElemX );
7838|  if ( p == NULL && nStroke == 0 )  {  ResetProp();  return; }
7839|  first = ( p == NULL ) ? NULL : (CadPrim*)p->p;
7840|
7841|  /* すべて同じタイプでないとき、警告する */
7842|  if ( nStroke > 0 )  p = ( first == NULL ) ? NULL : (ListX_ElemX*)prims->first;
7843|  else {
7844|    i = first->GetTypeID();
7845|    for ( ListX_forEach( prims, &p, ListX_ElemX ) ) {
7846|      if ( ((CadPrim*)p->p)->GetTypeID() != i )  break;
7847|    }
7848|  }
7849|  if ( p != NULL ) {
7850|    if ( type == -1 ) {
7851|      list->ResetContent();
7852|      if ( app->m_bJapanese ) {
7853|        list->AddString( "タイプ = 未選択" );
7854|        list->AddString( "" );
7855|        list->AddString( "選択している図形の種類が" );
7856|        list->AddString( "違うため、表示することが" );
7857|        list->AddString( "できませんが、タイプを" );
7858|        list->AddString( "制限すれば一部表示でき" );
7859|        list->AddString( "ます。" );
7860|      }
7861|      else {
7862|        list->AddString( "Type = not select yet" );
7863|        list->AddString( "" );
7864|        list->AddString( "Can not display, because" );
7865|        list->AddString( " the type of selected" );
7866|        list->AddString( " primitives are not same." );
7867|        list->AddString( "But selected type can" );
7868|        list->AddString( " display a part." );
7869|      }
7870|      m_PropPrim = first;
7871|      m_PropStrokes = strokes;
7872|      if ( prims != &m_PropPrims ) {
7873|        ListX_toEmptyDelete( &m_PropPrims, ListX_ElemX, NULL );
7874|        for ( ListX_forEach( prims, &p, ListX_ElemX ) ) {
7875|          p2 = ListX_addFirstMalloc( &m_PropPrims, ListX_ElemX );
7876|          p2->p = p->p;
7877|        }
7878|      }
7879|      return;
7880|    }
7881|  }
7882|  else {
7883|    if ( type == -1 )
7884|      { m_PropType = -2;  type = -2; }  /* 1つの型しかないのでタイプは選択しない */
7885|  }
7886|
7887|  list->ResetContent();
7888|
7889|
7890|  /* 図形のプロパティを表示する */
7891|  if ( nStroke == 0 || ( m_PropType != SVGCat_Ink_TypeID && m_PropType != -2 ) ) {
7892|
7893|    if ( m_PropType > 0 ) {
7894|      for ( ListX_forEach( prims, &p, ListX_ElemX ) ) {
7895|        if ( ((CadPrim*)p->p)->GetTypeID() == m_PropType )
7896|          { first = (CadPrim*)p->p;  break; }
7897|      }
7898|      ASSERT( p != NULL );
7899|    }
7900|    else
7901|      m_PropType = first->GetTypeID();
7902|
7903|    list->AddString( app->m_bJapanese ?  CString("タイプ = ") + first->GetTypeNameJp() :
7904|      CString("Type = ") + first->GetTypeNameEn() );
7905|
7906|    n = first->GetNProp();
7907|    for ( i =0; i < n; i++ ) {
7908|
7909|      /* 値が同じではないときは、「それぞれ」と表示する */
7910|      type = first->GetProp( i, app->m_bJapanese, name, sizeof(name), value0, sizeof(value0), app->m_path, &option );
7911|      for ( ListX_forEach( prims, &p, ListX_ElemX ) ) {
7912|        if ( ((CadPrim*)p->p)->GetTypeID() != m_PropType )  continue;
7913|        ((CadPrim*)p->p)->GetProp( i, app->m_bJapanese, name, sizeof(name), value, sizeof(value), app->m_path, &dummy );
7914|        if ( strcmp( value, value0 ) != 0 )  break;
7915|      }
7916|      if ( p != NULL ) {
7917|        if ( app->m_bJapanese )
7918|          list->AddString( CString( name ) + " =(それぞれ)" );
7919|        else
7920|          list->AddString( CString( name ) + " = (each value)" );
7921|      }
7922|
7923|      /* 値を表示する */
7924|      else {
7925|        if ( type == CadPrim_Select )
7926|          s = ListX_get( (ListX*)option, atoi( value ), StrX_ListElem ) ->p;
7927|        else
7928|          s = value;
7929|        list->AddString( CString( name ) + " = " + s );
7930|      }
7931|    }
7932|
7933|
7934|    if ( prims != &m_PropPrims ) {
7935|      ListX_toEmptyDelete( &m_PropPrims, ListX_ElemX, NULL );
7936|      for ( ListX_forEach( prims, &p, ListX_ElemX ) ) {
7937|        p2 = ListX_addFirstMalloc( &m_PropPrims, ListX_ElemX );
7938|        p2->p = p->p;
7939|      }
7940|    }
7941|  }
7942|
7943|  /* インクのプロパティを表示する */
7944|  else {
7945|    IInkDrawingAttributes**  attrs = (IInkDrawingAttributes**)malloc( sizeof(void*) * nStroke );
7946|    IInkStrokeDisp*  stroke;
7947|    long  color0, color;
7948|    float fvalue0, fvalue;
7949|    VARIANT_BOOL  value_b0, value_b;
7950|    CString  s;
7951|    char  ss[20];
7952|
7953|    list->AddString( app->m_bJapanese ? "タイプ = インク" : "Type = Ink" );
7954|
7955|    for ( i = 0; i < nStroke; i++ ) {
7956|      hr = strokes->Item( i, &stroke );  if ( hr != 0 )  error();
7957|      hr = stroke->get_DrawingAttributes( &attrs[i] );
7958|      if ( hr != 0 ) {  /* ディレイされた削除が原因? */
7959|        hr = strokes->Remove( stroke );
7960|        if ( hr != 0 )  error();
7961|        i--;  nStroke--;
7962|        stroke->Release();  stroke = NULL;
7963|        continue;
7964|      }
7965|      stroke->Release();  stroke = NULL;
7966|    }
7967|
7968|
7969|    hr = attrs[0]->get_Color( &color0 );  if ( hr != 0 )  error();
7970|    for ( i = 1; i < nStroke; i++ ) {
7971|      hr = attrs[i]->get_Color( &color );  if ( hr != 0 )  error();
7972|      if ( color != color0 )  break;
7973|    }
7974|    if ( i < nStroke ) {
7975|      if ( app->m_bJapanese )  list->AddString( "色 =(それぞれ)" );
7976|      else                     list->AddString( "Color = (each value)" );
7977|    }
7978|    else {
7979|      StrX_getColorStr( ss, color0 );
7980|      if ( app->m_bJapanese )  s.Format( "色 = %s", ss );
7981|      else                     s.Format( "Color = %s", ss );
7982|      list->AddString( s );
7983|    }
7984|
7985|    hr = attrs[0]->get_Width( &fvalue0 );  if ( hr != 0 )  error();
7986|    for ( i = 1; i < nStroke; i++ ) {
7987|      hr = attrs[i]->get_Width( &fvalue );  if ( hr != 0 )  error();
7988|      if ( fvalue != fvalue0 )  break;
7989|    }
7990|    if ( i < nStroke ) {
7991|      if ( app->m_bJapanese )  list->AddString( "幅 =(それぞれ)" );
7992|      else                     list->AddString( "Width = (each value)" );
7993|    }
7994|    else {
7995|      if ( app->m_bJapanese )  s.Format( "幅 = %d", (int)fvalue0 );
7996|      else                     s.Format( "Width = %d", (int)fvalue0 );
7997|      list->AddString( s );
7998|    }
7999|
8000|    hr = attrs[0]->get_IgnorePressure( &value_b0 );  if ( hr != 0 )  error();
8001|    for ( i = 1; i < nStroke; i++ ) {
8002|      hr = attrs[i]->get_IgnorePressure( &value_b );  if ( hr != 0 )  error();
8003|      if ( value_b != value_b0 )  break;
8004|    }
8005|    if ( i < nStroke ) {
8006|      if ( app->m_bJapanese )  list->AddString( "筆圧 =(それぞれ)" );
8007|      else                     list->AddString( "Pressure = (each value)" );
8008|    }
8009|    else {
8010|      if ( app->m_bJapanese )  s.Format( "筆圧 = %d", ! value_b0 );
8011|      else                     s.Format( "Pressure = %d", ! value_b0 );
8012|      list->AddString( s );
8013|    }
8014|
8015|    for ( i = 0; i < nStroke; i++ ) {
8016|      attrs[i]->Release();  attrs[i] = NULL;
8017|    }
8018|    free( attrs );
8019|  }
8020|
8021|  #ifndef  NDEBUG
8022|  sprintf( name, "Errors_X = %d", Errors_X );
8023|  list->AddString( name );
8024|  sprintf( name, "Errors_X2 = %d", Errors_X2 );
8025|  list->AddString( name );
8026|  sprintf( name, "Errors_X3 = %d", Errors_X3 );
8027|  list->AddString( name );
8028|  #endif
8029|
8030|  m_PropPrim = first;
8031|  m_PropStrokes = strokes;
8032|}
8033|
8034|
8035| 
8036|/***********************************************************************
8037|  15-6. <<< [CMainFrame::NoTree] ツリーを非表示にする >>> 
8038|  15-7. <<< [CMainFrame::OnSideByTree] ツリーを横に配置する >>>
8039|  15-8. <<< [CMainFrame::OnMaxTree] ツリーを最大化する >>>
8040|************************************************************************/
8041|void CMainFrame::NoTree()
8042|{
8043|  int  min;
8044|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
8045|
8046|  if ( app->m_SplitMode == 0 )
8047|    m_wndSplitter.GetColumnInfo( 0, app->m_SplitX, min );
8048|  m_wndSplitter.SetColumnInfo( 0, 0, 0 );
8049|  m_wndSplitter.RecalcLayout();
8050|  app->m_SplitMode = 1;
8051|}
8052|
8053|void CMainFrame::OnSideByTree()
8054|{
8055|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
8056|
8057|  if ( app->m_SplitMode == 0 )  NoTree();
8058|  else {
8059|    m_wndSplitter.SetColumnInfo( 0, app->m_SplitX, 0 );
8060|    m_wndSplitter.RecalcLayout();
8061|    app->m_SplitMode = 0;
8062|  }
8063|}
8064|
8065|void CMainFrame::OnMaxTree()
8066|{
8067|  int  min;
8068|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
8069|
8070|  if ( ListX_getN( &app->m_file.m_pages, SVGCat_Page ) + app->m_file.m_StartPageNum - 1 == 1 )
8071|    return;
8072|
8073|  if ( app->m_SplitMode == 0 )
8074|    m_wndSplitter.GetColumnInfo( 0, app->m_SplitX, min );
8075|  m_wndSplitter.SetColumnInfo( 0, 1000, 0 );
8076|  m_wndSplitter.RecalcLayout();
8077|  app->m_SplitMode = 2;
8078|}
8079|
8080|
8081| 
8082|/***********************************************************************
8083|  15-9. <<< [CMainFrame::GetLinkURL] リンク先の URL を返す >>> 
8084|【補足】
8085|・NULL は返しません。
8086|************************************************************************/
8087|char*  CMainFrame::GetLinkURL()
8088|{
8089|  CadPrim*  prim = m_wndView->m_HoldPrim;
8090|  const char*  url;
8091|
8092|  if ( prim == NULL )
8093|    url = "";
8094|  else if ( prim->GetTypeID() == Text_Box_TypeID )
8095|    url = ((Text_Box*)prim)->m_URL;
8096|  else if ( prim->GetTypeID() == Rect_Ex_TypeID )
8097|    url = ((Rect_Ex*)prim)->m_URL;
8098|  else
8099|    url = "";
8100|
8101|  if ( strncmp( url, "script:", 7 ) == 0 )
8102|    url = "";
8103|
8104|  return  (char*)url;
8105|}
8106|
8107| 
8108|void CMainFrame::OnInputLicense() 
8109|{
8110|  CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
8111|  CInputDlg1   dlg;
8112|  time_t  licensedDay;
8113|  time_t  now;
8114|  time_t  days10;
8115|  time_t  last;
8116|  struct  tm*  last2;
8117|
8118|  dlg.m_Msg = "キーナンバー";
8119|
8120|  app->ReloadKeyNumber();
8121|  licensedDay = app->MeltKeyNumber( app->m_KeyNumber );
8122|  time( &now );
8123|  TimeDate_setDiff( &days10, 0, 0, 10, 0, 0, 0 );
8124|  last = licensedDay + days10 - now;
8125|  last2 = gmtime( &last );
8126|
8127|  if ( (signed)last < 0 || (signed)(now - licensedDay) < 0 )
8128|    dlg.m_Msg += "  (ライセンスが切れています)";
8129|  else {
8130|    CString  fmt;
8131|
8132|    if ( last2->tm_mday == 11 ) {
8133|      MessageBox("購入ライセンスが既に登録されています。");
8134|      return;
8135|    }
8136|    else
8137|      fmt.Format( "  (あと%d日試用いただけます)", last2->tm_mday );
8138|      /* あと10日〜あと1日の10日間 */
8139|    dlg.m_Msg += fmt;
8140|  }
8141|
8142|  dlg.m_Text = "";
8143|  dlg.m_bPath = false;
8144|  dlg.m_PenInputPanel = m_wndView->m_PenInputPanel;
8145|  dlg.m_bSetAtCursor = true;
8146|  if ( dlg.DoModal() == IDOK ) {
8147|    strncpy( app->m_KeyNumber, dlg.m_Text, sizeof(app->m_KeyNumber)-1 );
8148|    app->m_KeyNumber[ sizeof(app->m_KeyNumber)-1 ] = '\0';
8149|    licensedDay = app->MeltKeyNumber( dlg.m_Text );
8150|    last = licensedDay + days10 - now;
8151|    last2 = gmtime( &last );
8152|    if ( (signed)last < 0 || (signed)(now - licensedDay) < 0 ) {
8153|      if ( licensedDay == (time_t) 0 )
8154|        MessageBox( "キーナンバー・エラー" );
8155|      else if ( last2->tm_mday == 11 ) {
8156|        MessageBox( "購入ライセンスが登録されました! ありがとうございます。" );
8157|        app->SaveSVGCatsIni(false);
8158|      }
8159|      else
8160|        MessageBox( "試用期限が切れているキーナンバーです" );
8161|    }
8162|    else {
8163|      MessageBox( "試用期間が延長されました。" );
8164|      app->SaveSVGCatsIni(false);
8165|    }
8166|  }
8167|}
8168| 
8169|/***********************************************************************
8170|  15-10. <<< [CMainFrame::OnActivate] アクティブになったときの処理 >>> 
8171|************************************************************************/
8172|void CMainFrame::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
8173|{
8174|  CFrameWnd::OnActivate(nState, pWndOther, bMinimized);
8175|
8176|  if ( nState == WA_CLICKACTIVE ) {
8177|    RECT  rc;
8178|    POINT  pt;
8179|
8180|    m_wndView->GetWindowRect( &rc );
8181|    GetCursorPos( &pt );
8182|
8183|    if ( pt.x >= rc.left && pt.x <= rc.right && pt.y >= rc.top && pt.y <= rc.bottom )
8184|      m_bMouseActivated = true;
8185|  }
8186|  if ( nState == WA_ACTIVE || nState == WA_CLICKACTIVE ) {
8187|    CSVGCatApp*  app = (CSVGCatApp*)AfxGetApp();
8188|    app->ReadRecentFile();
8189|    SetRecentFileMenu();
8190|  }
8191|  m_bActivated = ( nState != WA_INACTIVE );
8192|
8193|  if ( m_wndView->m_InkOverlay != NULL )
8194|    m_wndView->m_InkOverlay->put_MousePointer( m_bActivated ? IMP_Default : IMP_Arrow );
8195|}
8196|
8197|
8198| 
8199|/***********************************************************************
8200|  15-11. <<< [CMainFrame::OnSysColorChange] システムの色や画面の色数が変更されたときの処理 >>> 
8201|************************************************************************/
8202|void CMainFrame::OnSysColorChange()
8203|{
8204|	CFrameWnd::OnSysColorChange();
8205|
8206|  /* DDB タイプのイメージのキャッシュファイルを削除する */
8207|  {
8208|    HANDLE  f;
8209|    WIN32_FIND_DATA  d;
8210|    char  path[_MAX_PATH];
8211|    int  len;
8212|
8213|    StrX_getExeFullPath( path, _work_path, sizeof(path) );
8214|    len = strlen( path ) + 1;
8215|    sprintf( path + len - 1, "\\img_%08X_*.ddb", m_hWnd );
8216|    f = FindFirstFile( path, &d );
8217|    if ( (int)f != -1 ) {
8218|      do {
8219|        strcpy( path + len, d.cFileName );
8220|        remove( path );
8221|      } while ( FindNextFile( f, &d ) );
8222|      FindClose( f );
8223|    }
8224|  }
8225|
8226|  /* 念のため再描画する */
8227|  m_wndView->Redraw( true );
8228|}
8229|
8230| 
8231|void CMainFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) 
8232|{
8233|  if ( m_bScopeMode ) {
8234|    RECT  rect;
8235|
8236|    /* スコープモードで最大化を選んだとき、アニメーション表示中に最大化しない */
8237|    GetWindowRect( &rect );
8238|    lpMMI->ptMaxPosition.x = rect.left;
8239|    lpMMI->ptMaxPosition.y = rect.top;
8240|    lpMMI->ptMaxSize.x = rect.right - rect.left + 1;
8241|    lpMMI->ptMaxSize.y = rect.bottom - rect.top;
8242|  }
8243|
8244|	CFrameWnd::OnGetMinMaxInfo(lpMMI);
8245|}
8246|
8247| 
8248|
8249|void CMainFrame::OnSize(UINT nType, int cx, int cy) 
8250|{
8251|  static  UINT  nType_prev = 0;
8252|
8253|	CFrameWnd::OnSize(nType, cx, cy);
8254|  if ( Errors_bExiting )  return;
8255|
8256|  m_PropBar.OnParentSize( nType, cx, cy );
8257|
8258|  nType_prev = nType;
8259|}
8260|