/*
* Copyright 2004 Perforce Software. All rights reserved.
*
* Developed by Data Shades Ltd.
*/
#include <stdio.h>
#include <windows.h>
#define P4PHOTOSHOP_MAIN
#include "P4GTPhotoshop.h"
#include "PerforceMenu.h"
#include "UglyDialog.h"
#include "PIUSuites.h"
#ifdef _DEBUG
#include "debug.h"
#endif
/*
* PluginMain
*
* All calls to the plug-in module come through this routine.
* It must be placed first in the resource. To achieve this,
* most development systems require this be the first routine
* in the source.
*
* caller - Who is calling
* selector - What do they want
* data - What is the message
*
*/
static bool bDlgActive = false;
static UglyDialog* sUglyDialog = NULL;
DLLExport SPAPI SPErr PluginMain( const char* caller, const char* selector, const void* data )
{
SPErr error = kSPNoError;
SPMessageData *basicMessage = NULL;
//all messages contain a SPMessageData*
basicMessage = ( SPMessageData * )data;
sSPBasic = basicMessage->basic;
// Acuire Photoshop suites
AutoSuite<PSActionDescriptorProcs> sPSActionDescriptor(kPSActionDescriptorSuite, kPSActionDescriptorSuiteVersion);
AutoSuite<PSActionReferenceProcs> sPSActionReference(kPSActionReferenceSuite, kPSActionReferenceSuiteVersion);
AutoSuite<PSActionControlProcs> sPSActionControl(kPSActionControlSuite, kPSActionControlSuitePrevVersion);
AutoSuite<PSActionListProcs> sPSActionList(kPSActionListSuite, kPSActionListSuiteVersion);
AutoSuite<PSHandleSuite2> sPSHandle(kPSHandleSuite, kPSHandleSuiteVersion1);
AutoSuite<PSUIHooksSuite1> sPSUIHooks(kPSUIHooksSuite, kPSUIHooksSuiteVersion1);
// AutoSuite<ADMBasicSuite> sADMBasic(kADMBasicSuite, kADMBasicSuiteVersion); // Adobe Dialog Manager has been deprecated and no longer works. There is currently no direct replacement for the ADM API. Plug-in developers must write their UI using the API's provided by the OS.
// check for SP interface callers
if ( sSPBasic->IsEqual( ( char* )caller, kSPInterfaceCaller ) ) {
// if ( sSPBasic->IsEqual( ( char* )selector, kSPInterfaceAboutSelector ) ) {
//
// // Popup the About box using sADMBasic
// sADMBasic->AboutBox( basicMessage->self, "About P4Photoshop",
// "P4Photoshop is an automation plug-in" );
// }
// else if ( sSPBasic->IsEqual( ( char* )selector, kSPInterfaceStartupSelector ) ) {
// }
if ( sSPBasic->IsEqual( ( char* )selector, kSPInterfaceShutdownSelector ) ) {
// Plugin shutdown
if ( bDlgActive ) {
if ( host->GetWin() )
DestroyWindow( host->GetWin() );
delete host;
delete perforceOps;
callbacks->Remove( basicMessage->self );
delete callbacks;
RemovePerforceWndProc();
}
}
}
if ( sSPBasic->IsEqual( ( char* )caller, kSPAccessCaller ) ) {
//if ( sSPBasic->IsEqual( ( char* )selector, kSPAccessReloadSelector ) ) {
//}
//if (sSPBasic->IsEqual((char*)selector, kSPAccessUnloadSelector)) {
//}
}
// Photoshop is calling
if ( sSPBasic->IsEqual( ( char* )caller, kPSPhotoshopCaller ) ) {
// the one and only message
if ( sSPBasic->IsEqual( ( char* )selector, kPSDoIt ) ) {
if ( !bDlgActive || host->Closing() ) {
// Plugin startup here for CS4 and later
sUglyDialog = new UglyDialog( GetActiveWindow() );
sUglyDialog->InitDialog();
host = new PhotoshopHost( hInstance, sUglyDialog->m_hWnd );
perforceOps = new PluginOperations( host );
callbacks = new CallbackManager( basicMessage->self );
InstallPerforceWndProc();
bDlgActive = true;
}
// else {
// //pop a dialog to show plug-in works
// sADMBasic->MessageAlert( "P4Photoshop Automation Plug-In" );
// }
}
}
return error;
}
// All windows plug-ins need a DllMain
#ifdef __PIWin__
BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved )
{
static int G_processes = 0;
switch ( ul_reason_for_call ) {
case DLL_PROCESS_ATTACH:
if ( G_processes == 0 ) {
#ifdef _DEBUG
DBG_open();
#endif
// Save plugin instance handle
hInstance = (HINSTANCE)hModule;
}
G_processes++;
break;
case DLL_PROCESS_DETACH:
G_processes--;
if ( G_processes == 0 ) {
#ifdef _DEBUG
DBG_close();
#endif
}
break;
}
return TRUE;
}
#endif
# |
Change |
User |
Description |
Committed |
|
#1
|
10140 |
Matt Attaway |
Initial release of the P4GT source code. |
|
|