| 
									
										
										
										
											2007-11-17 02:25:45 +08:00
										 |  |  | /* ASE - Allegro Sprite Editor
 | 
					
						
							| 
									
										
										
										
											2009-01-24 08:41:01 +08:00
										 |  |  |  * Copyright (C) 2001-2009  David Capello | 
					
						
							| 
									
										
										
										
											2007-09-24 04:13:58 +08:00
										 |  |  |  * | 
					
						
							|  |  |  |  * This program is free software; you can redistribute it and/or modify | 
					
						
							|  |  |  |  * it under the terms of the GNU General Public License as published by | 
					
						
							|  |  |  |  * the Free Software Foundation; either version 2 of the License, or | 
					
						
							|  |  |  |  * (at your option) any later version. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  |  * GNU General Public License for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * You should have received a copy of the GNU General Public License | 
					
						
							|  |  |  |  * along with this program; if not, write to the Free Software | 
					
						
							|  |  |  |  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "config.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-12-05 09:30:50 +08:00
										 |  |  | #include "jinete/jbase.h"
 | 
					
						
							| 
									
										
										
										
											2007-09-24 04:13:58 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-12-05 09:30:50 +08:00
										 |  |  | #include "commands/commands.h"
 | 
					
						
							| 
									
										
										
										
											2007-09-24 04:13:58 +08:00
										 |  |  | #include "modules/sprites.h"
 | 
					
						
							| 
									
										
										
										
											2007-09-30 23:32:21 +08:00
										 |  |  | #include "raster/layer.h"
 | 
					
						
							|  |  |  | #include "raster/mask.h"
 | 
					
						
							| 
									
										
										
										
											2007-09-24 04:13:58 +08:00
										 |  |  | #include "raster/sprite.h"
 | 
					
						
							| 
									
										
										
										
											2009-03-08 03:14:40 +08:00
										 |  |  | #include "util/clipboard.h"
 | 
					
						
							| 
									
										
										
										
											2007-09-30 23:32:21 +08:00
										 |  |  | #include "util/misc.h"
 | 
					
						
							| 
									
										
										
										
											2007-09-24 04:13:58 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-12-05 09:30:50 +08:00
										 |  |  | static bool cmd_copy_enabled(const char *argument) | 
					
						
							| 
									
										
										
										
											2007-09-30 23:32:21 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-06-01 10:59:15 +08:00
										 |  |  |   CurrentSprite sprite; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if ((!sprite) || | 
					
						
							|  |  |  |       (!sprite->layer) || | 
					
						
							|  |  |  |       (!layer_is_readable(sprite->layer)) || | 
					
						
							|  |  |  |       (!layer_is_writable(sprite->layer)) || | 
					
						
							|  |  |  |       (!sprite->mask) || | 
					
						
							|  |  |  |       (!sprite->mask->bitmap)) | 
					
						
							|  |  |  |     return false; | 
					
						
							| 
									
										
										
										
											2007-09-30 23:32:21 +08:00
										 |  |  |   else | 
					
						
							| 
									
										
										
										
											2009-06-01 10:59:15 +08:00
										 |  |  |     return GetImage(sprite) ? true: false; | 
					
						
							| 
									
										
										
										
											2007-09-30 23:32:21 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-12-05 09:30:50 +08:00
										 |  |  | static void cmd_copy_execute(const char *argument) | 
					
						
							| 
									
										
										
										
											2007-09-24 04:13:58 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-06-01 10:59:15 +08:00
										 |  |  |   CurrentSprite sprite; | 
					
						
							|  |  |  |   clipboard::copy(sprite); | 
					
						
							| 
									
										
										
										
											2007-09-24 04:13:58 +08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2007-12-05 09:30:50 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | Command cmd_copy = { | 
					
						
							|  |  |  |   CMD_COPY, | 
					
						
							|  |  |  |   cmd_copy_enabled, | 
					
						
							|  |  |  |   NULL, | 
					
						
							|  |  |  |   cmd_copy_execute, | 
					
						
							|  |  |  |   NULL | 
					
						
							|  |  |  | }; |