Rev 237 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 237 | Rev 259 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | /* |
1 | /* |
2 | This file is part of a common library for Adobe(R) Illustrator(R) plugins |
2 | This file is part of a common library for Adobe(R) Illustrator(R) plugins |
3 | Copyright (C) 2002-6 Toby Thain, toby@telegraphics.com.au |
3 | Copyright (C) 2002-6 Toby Thain, toby@telegraphics.com.au |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify |
5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by |
6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or |
7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. |
8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, |
10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. |
13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License |
15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software |
16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | */ |
18 | */ |
19 | 19 | ||
20 | #include <stdio.h> |
20 | #include <stdio.h> |
21 | 21 | ||
22 | #include "aipluginmain.h" |
22 | #include "aipluginmain.h" |
23 | 23 | ||
24 | DLLEXPORT SPAPI |
24 | DLLEXPORT SPAPI |
25 | PLUGINRETURN ENTRYPOINT( char *caller, char *selector, SPMessageData *message ){ |
25 | PLUGINRETURN ENTRYPOINT( char *caller, char *selector, SPMessageData *message ){ |
26 | SPBasicSuite *b = message->basic; |
26 | SPBasicSuite *b = message->basic; |
27 | SPErr e = kSPNoError; |
27 | SPErr e = kSPNoError; |
28 | 28 | ||
29 | EnterCodeResource(); |
29 | EnterCodeResource(); |
30 | 30 | ||
31 | // char s[0x100]; sprintf(s,"PluginMain(\"%s\",\"%s\")",caller,selector); dbg(s); |
31 | // char s[0x100]; sprintf(s,"PluginMain(\"%s\",\"%s\")",caller,selector); dbg(s); |
32 | 32 | ||
33 | if( message->SPCheck == kSPValidSPMessageData ){ |
33 | if( message->SPCheck == kSPValidSPMessageData ){ |
34 | 34 | ||
35 | if(b->IsEqual(caller, kSPInterfaceCaller)){ |
35 | if(b->IsEqual(caller, kSPInterfaceCaller)){ |
36 | if(b->IsEqual(selector, kSPInterfaceStartupSelector)) |
36 | if(b->IsEqual(selector, kSPInterfaceStartupSelector)) |
37 | e = plugin_startup( (SPInterfaceMessage*)message ); |
37 | e = plugin_startup( (SPInterfaceMessage*)message ); |
38 | else if(b->IsEqual(selector, kSPInterfaceShutdownSelector)){ |
38 | else if(b->IsEqual(selector, kSPInterfaceShutdownSelector)){ |
39 | e = plugin_shutdown( (SPInterfaceMessage*)message ); |
39 | e = plugin_shutdown( (SPInterfaceMessage*)message ); |
40 | }else if(b->IsEqual(selector, kSPInterfaceAboutSelector)) |
40 | }else if(b->IsEqual(selector, kSPInterfaceAboutSelector)) |
41 | e = plugin_about( (SPInterfaceMessage*)message ); |
41 | e = plugin_about( (SPInterfaceMessage*)message ); |
42 | } |
42 | } |
43 | #ifdef ISFILTER |
43 | #ifdef ISFILTER |
44 | else if(b->IsEqual(caller, kCallerAIFilter)){ |
44 | else if(b->IsEqual(caller, kCallerAIFilter)){ |
45 | if(b->IsEqual(selector, kSelectorAIGoFilter)) |
45 | if(b->IsEqual(selector, kSelectorAIGoFilter)) |
46 | e = filter_go( (AIFilterMessage*)message ); |
46 | e = filter_go( (AIFilterMessage*)message ); |
47 | } |
47 | } |
48 | #endif |
48 | #endif |
49 | #ifdef ISTOOL |
49 | #ifdef ISTOOL |
50 | else if(b->IsEqual( caller, kCallerAITool)){ |
50 | else if(b->IsEqual( caller, kCallerAITool)){ |
51 | if(b->IsEqual(selector, kSelectorAIEditToolOptions)) |
51 | if(b->IsEqual(selector, kSelectorAIEditToolOptions)) |
52 | e = toolOptions( (AIToolMessage*)message ); |
52 | e = toolOptions( (AIToolMessage*)message ); |
53 | else if(b->IsEqual(selector, kSelectorAITrackToolCursor)) |
53 | else if(b->IsEqual(selector, kSelectorAITrackToolCursor)) |
54 | e = toolTrackCursor( (AIToolMessage*)message ); |
54 | e = toolTrackCursor( (AIToolMessage*)message ); |
55 | else if(b->IsEqual(selector, kSelectorAIToolMouseDown)) |
55 | else if(b->IsEqual(selector, kSelectorAIToolMouseDown)) |
56 | e = toolMouseDown( (AIToolMessage*)message ); |
56 | e = toolMouseDown( (AIToolMessage*)message ); |
57 | else if(b->IsEqual(selector, kSelectorAIToolMouseDrag)) |
57 | else if(b->IsEqual(selector, kSelectorAIToolMouseDrag)) |
58 | e = toolMouseDrag( (AIToolMessage*)message ); |
58 | e = toolMouseDrag( (AIToolMessage*)message ); |
59 | else if(b->IsEqual(selector, kSelectorAIToolMouseUp)) |
59 | else if(b->IsEqual(selector, kSelectorAIToolMouseUp)) |
60 | e = toolMouseUp( (AIToolMessage*)message ); |
60 | e = toolMouseUp( (AIToolMessage*)message ); |
61 | else if(b->IsEqual(selector, kSelectorAISelectTool)) |
61 | else if(b->IsEqual(selector, kSelectorAISelectTool)) |
62 | e = toolSelect( (AIToolMessage*)message ); |
62 | e = toolSelect( (AIToolMessage*)message ); |
63 | else if(b->IsEqual(selector, kSelectorAIDeselectTool)) |
63 | else if(b->IsEqual(selector, kSelectorAIDeselectTool)) |
64 | e = toolDeselect( (AIToolMessage*)message ); |
64 | e = toolDeselect( (AIToolMessage*)message ); |
65 | } |
65 | } |
66 | #endif |
66 | #endif |
67 | 67 | ||
68 | }else{ |
68 | }else{ |
69 | char s[0x100]; |
69 | char s[0x100]; |
70 | sprintf(s,"invalid SPCheck (caller=\"%s\",selector=\"%s\")",caller,selector); |
70 | sprintf(s,"invalid SPCheck (caller=\"%s\",selector=\"%s\")",caller,selector); |
71 | dbg(s); |
71 | dbg(s); |
72 | } |
72 | } |
73 | 73 | ||
74 | ExitCodeResource(); |
74 | ExitCodeResource(); |
75 | 75 | ||
76 | return e; |
76 | return e; |
77 | } |
77 | } |
78 | 78 | ||
79 | SPErr acq_suite(SPMessageData *m, char *name, long version, ppsuite suite) |
79 | SPErr acq_suite(SPMessageData *m, char *name, long version, ppsuite suite) |
80 | { |
80 | { |
81 | unsigned long e = m->basic->AcquireSuite(name, version, suite); |
81 | unsigned long e = m->basic->AcquireSuite(name, version, suite); |
82 | if(e){ |
82 | if(e){ |
83 | char s[0x200], ai_vers[16]; |
83 | char s[0x200], ai_vers[16]; |
84 | 84 | ||
85 | // version is BCD encoded, e.g. 0xNN000000 |
85 | // version is BCD encoded, e.g. 0xNN000000 |
86 | int v = 10*(kPluginInterfaceVersion >> 28) + ((kPluginInterfaceVersion >> 24) & 0xf); |
86 | int v = 10*(kPluginInterfaceVersion >> 28) + ((kPluginInterfaceVersion >> 24) & 0xf); |
87 | 87 | ||
88 | if(v > 10) |
88 | if(v > 10) |
89 | sprintf(ai_vers, "CS%c", v > 11 ? v+'1'-11 : ' '); |
89 | sprintf(ai_vers, "CS%c", v > 11 ? v+'1'-11 : ' '); |
90 | else |
90 | else |
91 | sprintf(ai_vers, "%d", v); |
91 | sprintf(ai_vers, "%d", v); |
92 | 92 | ||
93 | sprintf(s, "Could not load the plugin.\n\n" |
93 | sprintf(s, "Could not load the plugin.\n\n" |
94 | "This plugin was built for Illustrator %s.\n\n" |
94 | "This plugin was built for Illustrator %s.\n\n" |
95 | "Please obtain the correct version for your installation " |
95 | "Please obtain the correct version for your installation " |
96 | "from https://www.telegraphics.com.au/sw/\n" |
96 | "from https://www.telegraphics.com.au/sw/\n" |
97 | "or contact support@telegraphics.com.au if you cannot resolve the problem.\n\n" |
97 | "or contact support@telegraphics.com.au if you cannot resolve the problem.\n\n" |
98 | "Details: AcquireSuite failed \"%s\" (%ld): %c%c%c%c", |
98 | "Details: AcquireSuite failed \"%s\" (%ld): %c%c%c%c", |
99 | ai_vers, name, version, (int)(e>>24), (int)(e>>16), (int)(e>>8), (int)e); |
99 | ai_vers, name, version, (int)(e>>24), (int)(e>>16), (int)(e>>8), (int)e); |
100 | dbg(s); |
100 | dbg(s); |
101 | } |
101 | } |
102 | return e; |
102 | return e; |
103 | } |
103 | } |