Click here to Skip to main content
Click here to Skip to main content
 
Add your own
alternative version

A Simple, Action Based, Undo/Redo Framework

, 16 Feb 2013 CPOL
How to use a simple, action based, undo/redo framework
kiswinbin_v_1.zip
kis
kis.dll
kis.lib
KisWinBin_v_1_r_1.zip
KisWinBin_v_1_r_1
kis
kis.dll
kis.lib
kiswinsrc_v_1.zip
KisActionDemo
res
KisActionDemo.ico
KisActionDemoDoc.ico
Toolbar.bmp
vssver.scc
KisWinSrc_v_1_r_1.zip
KisWinSrc_v_1_r_1
kis
KisActionDemo
res
KisActionDemo.ico
KisActionDemoDoc.ico
Toolbar.bmp
vssver.scc
/*
***************************************************************************

kis v 1

(c) 2006, Florin DUMITRESCU

mailto: fdproxy@gmail.com

$Workfile: KisActionDemo.cpp $ 

***************************************************************************
*/


#include "stdafx.h"
#include "kisactiondemo.h"
#include "KisActionDemoDoc.h"
#include "ChildFrm.h"
#include "KisActionDemoView.h"
#include "MainFrm.h"
#include "afxcmn.h"
#include ".\kisactiondemo.h"
#include "_Factory.h"
#include "resource.h"


#ifdef _DEBUG
#define new DEBUG_NEW
#endif


CKisActionDemoApp theApp;


class CAboutDlg : public CDialog
{
	DECLARE_MESSAGE_MAP()
public:
	enum { IDD = IDD_ABOUTBOX };
  CAboutDlg() : CDialog(CAboutDlg::IDD)
  {
  }
};


BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()


BEGIN_MESSAGE_MAP(CKisActionDemoApp, CWinApp)
	ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
	ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
	ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
	ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
  ON_COMMAND(ID_ACTION_CHANGE_OPTIONS, OnActionChangeOptions)
END_MESSAGE_MAP()


CKisActionDemoApp::CKisActionDemoApp()
:
m_UndoRedoMemorySize( 512 ),
m_spActionExecutor( C_Factory().CreateActionExecutor() )
{
  // nop
}


BOOL CKisActionDemoApp::InitInstance()
{
	CWinApp::InitInstance();

	// Standard initialization
	// If you are not using these features and wish to reduce the size
	// of your final executable, you should remove from the following
	// the specific initialization routines you do not need
	// Change the registry key under which our settings are stored
	// TODO: You should modify this string to be something appropriate
	// such as the name of your company or organization
	SetRegistryKey(_T("Local AppWizard-Generated Applications"));
	LoadStdProfileSettings(4);  // Load standard INI file options (including MRU)
	// Register the application's document templates.  Document templates
	//  serve as the connection between documents, frame windows and views
	CMultiDocTemplate* pDocTemplate;
	pDocTemplate = new CMultiDocTemplate(IDR_KISACTIONDEMOTYPE,
		RUNTIME_CLASS(CKisActionDemoDoc),
		RUNTIME_CLASS(CChildFrame), // custom MDI child frame
		RUNTIME_CLASS(CKisActionDemoView));
	if (!pDocTemplate)
		return FALSE;
	AddDocTemplate(pDocTemplate);
	// create main MDI Frame window
	CMainFrame* pMainFrame = new CMainFrame;
	if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME))
		return FALSE;
	m_pMainWnd = pMainFrame;
	// call DragAcceptFiles only if there's a suffix
	//  In an MDI app, this should occur immediately after setting m_pMainWnd
	// Enable drag/drop open
	m_pMainWnd->DragAcceptFiles();
	// Enable DDE Execute open
	EnableShellOpen();
	RegisterShellFileTypes(TRUE);
	// Parse command line for standard shell commands, DDE, file open
	CCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);
	// Dispatch commands specified on the command line.  Will return FALSE if
	// app was launched with /RegServer, /Register, /Unregserver or /Unregister.
	if (!ProcessShellCommand(cmdInfo))
		return FALSE;
	// The main window has been initialized, so show and update it
	pMainFrame->ShowWindow(m_nCmdShow);
	pMainFrame->UpdateWindow();
	return TRUE;
}


void CKisActionDemoApp::OnAppAbout()
{
	CAboutDlg aboutDlg;
	aboutDlg.DoModal();
}


void CKisActionDemoApp::OnActionChangeOptions()
{
  m_spActionExecutor->Execute( C_Factory().CreateAction_ClearDrawing() ); 
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

zdf

Romania Romania
Just a humble programmer.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150414.1 | Last Updated 16 Feb 2013
Article Copyright 2006 by zdf
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid