TweetFollow Us on Twitter

REALbasic Plug-in Development

Volume Number: 18 (2002)
Issue Number: 07
Column Tag: Getting Started

by Erick J. Tejkowski

REALbasic Plug-in Development

Plugging Made Easy

Introduction

Back in late 1999, we first discussed REALbasic plug-ins in MacTech. Since then, much has changed. REAL Software has released several improvements to the REALbasic plug-in SDK, countless developers have created plug-ins, and lots more plug-in code is out there for you to explore. Because so much has changed, we revisit the topic of REALbasic plug-in development this month. As we did nearly three years ago, we will examine the process of creating plug-ins for REALbasic. We will start with a brief description of the plug-in SDK features. Then, we will prepare the compiler for REALbasic plug-ins. Finally, we will code some plug-in examples so you can see how it all works. In the process, we will discuss what has changed in the SDK during the past three years. If you are completely new to REALbasic plug-in programming, this article should give you a good start on learning the skill.

Plug-in Fundamentals

When we last looked at the REALbasic plug-in SDK in 1999, plug-ins could be compatible either 68K or PPC Macintosh applications. Since then, REAL Software added Microsoft Windows and Macintosh Carbon targets to the list of REALbasic’s abilities. Starting with REALbasic 4, they also removed support for the 68K target. This means that the current REALbasic plug-in SDK supports the creation of PPC, Carbon, and Win32 plug-ins. Each plug-in can contain any combination of these targets, but it must always be compatible with the platform where you are using REALbasic. For example, if you plan to use the plug-in with a Classic version of REALbasic, your plug-in must have a PPC-compatible version for it to work. Likewise, the Carbon version of REALbasic requires a Carbon-compatible version of the plug-in.

A REALbasic plug-in consists of one or more code resources. The following list shows each possible target platform and its corresponding resource name:

  • Carbon – ‘PLCN’
  • PowerPC (PPC) – ‘PLPC’
  • Win32 – ‘PL86’

Plug-in resources start at resource ID #128 and increment from there on. However, you will seldom or never have more than one resource for each target. Thus, most plug-ins that you build will have one resource (#128) for each target (i.e. ‘PLPC’, ‘PLCN’, and ‘PL86’).

The current REALbasic plug-in SDK gives you the ability to create the following items:

  • Classes
  • Class Extensions
  • Controls
  • Functions
  • Database Engines

In this article, we will look at how to implement each of these, except database engines.

Before you embark upon any REALbasic plug-in development, you should first visit REAL Software’s web site and pick up a copy of the latest plug-in SDK. The SDK URL appears at the end of this article in the Bibliography section.

Prepare the Compiler

To begin creating REALbasic plug-ins, you will need a compiler. The tool of choice here is Metrowerk’s CodeWarrior. Since REALbasic plug-ins must contain PEF code resources, Apple’s Project Builder is not suitable for the task. Project Builder can only create Mach-O code.

The easiest way to build a plug-in is to use one of the example projects included with the REALbasic plug-in SDK as a base. If you prefer to start from scratch instead, create a folder in the Finder named “MacTech Plug-in”. Next, open your copy of the REALbasic plug-in SDK and copy the folders named “Glue Code” and “Includes” into the “MacTech Plug-in” folder. Then, launch CodeWarrior.

Create a new project in CodeWarrior using the Mac OS C Stationery. In the resulting New Project dialog that appears, select the Mac OS Toolbox: MacOS Toolbox PPC project stationery as shown in Figure 1.


Figure 1. Choose Mac OS Toolbox PPC Project Stationery to begin building a plug-in

Since a REALbasic plug-in is a code resource, you need to make some changes to the settings of your CodeWarrior project. From the Targets tab, control-click the target named “Classic Toolbox Debug” and select clear from the resulting popup menu. If you based your project on the Classic Toolbox stationery, the remaining target will be named “Classic Toolbox Final”.

Select Classic Toolbox Final Settings from the Edit menu. This displays the settings panels for the current target. In the Target Settings Panel, change the Target Name to “PPC Plug-in”. Next, choose the Access Paths Panel and add a path to the “Includes” folder you copied earlier. Then, select the PPC Target Panel and adjust it to look like Figure 2. Note that the Creator field has changed since we last examined plug-ins in 1999. It is now ‘RBv2’.


Figure 2. PPC Target Settings Panel

Finally, select the PPC Linker Panel and change it to match Figure 3. When you are finished, close the Settings window to return to the Project window.


Figure 3. PPC Linker Panel Settings

If you would like to create targets for Carbon or Win32, consult the REALbasic Plug-in SDK in the “Targeting New Platforms” section. The process works much the same way, but you will need to make a few tweaks specific to each platform.

Again, your best bet for starting out is to use one of the plug-in examples available in the SDK. Those examples have already made the necessary project settings for each platform. Simply copy the folder that contains one of these projects, and rename it to your liking. Once opened, you may want to alter the “Filename” setting in the PPC or X86 Target Panels for each target. You may also need to change the Access Paths Panel to match your directory structure. Other than that, a pre-made plug-in is ready to go and can greatly simplify your life. Use them whenever possible!

Global Methods

By this point, you should have a plug-in project shell that needs some code. As mentioned earlier, we will look at implementing global functions, classes, class extensions, and controls. The plug-in will focus on QuickTime. QuickTime has a large set of functions that are compatible for PPC, Carbon, and Win32. This simplifies matters, because you can often use the same code for multiple targets; even decidedly “Mac-looking” code works with Win32. It is also handy for REALbasic users, because REALbasic does not have some of these QuickTime features.

The simplest construct you can create in a REALbasic plug-in is a global method. Simply create a function as you normally would. For example, Listing 1 shows how to toggle the HighQuality setting of a REALmovie.

Listing 1: Toggle the HighQuality Setting of a REALmovie

SetMoviePlayHintsFunc

static void SetMoviePlayHintsFunc( REALmovie theMovie, Boolean theState)
{
	QT::Movie aMovie;
	
	//get the QT movie from the REALmovie struct
	aMovie = REALgetMovieMovie( theMovie );
	
	//if we have a movie, set it's highQuality on/off
	if (aMovie)
	{
		if (theState)
			SetMoviePlayHints
				(aMovie, hintsHighQuality, hintsHighQuality);
		else
			SetMoviePlayHints(aMovie, 0, hintsHighQuality);
	}

}

Note the REALmovie parameter in the SetMoviePlayHintsFunc function. A REALbasic user will want to pass a REALbasic movie to this function. We must then convert it to a QuickTime movie for use with standard QuickTime API calls. REALgetMovieMovie does this job for us. REALgetMovieMovie is a function provided by the REALbasic Plug-in SDK. The documentation for the Plug-in SDK lists all of the functions that are available to plug-in developers. The bulk of the SDK functions help you to convert back and forth between REALbasic and C/C++ data types and structures.

To let your plug-in know about this function, you must define it using code like that shown in Listing 2.

Listing 2: Define a Global Function

SetMoviePlayHintsMethod 
REALmethodDefinition SetMoviePlayHintsMethod = 
	{ (REALproc) SetMoviePlayHintsFunc, REALnoImplementation, "SetMoviePlayHints(theMovie as Movie, state as Boolean)" };

SetMoviePlayHintsMethod is the name of the REALmethod within the plug-in code. When you call from REALbasic, the SetMoviePlayHintsFunc function in turn is called. The last part of the REALmethodDefinition shows how the call appears to REALbasic users. Choose your phony parameter names carefully here, because they are what appear in the Tips window of REALbasic. Figure 4 shows what the Tips Window looks like when invoked for the SetMoviePlayHints method.


Figure 4. The Tips Window displays a function’s parameter names, but no data types.

The final step in adding a global function to a REALbasic plug-in is to register it. Every REALbasic plug-in has a PluginEntry function. It is here that you register the plug-in’s methods, classes, extensions, and controls. Listing 3 shows how to register the SetMoviePlayHintsMethod via a PluginEntry function.

Listing 3: The PluginEntry Function

The PluginEntry function is the entry point of a plug-in. Here you register the various items (classes, controls, methods, etc..) that you want included in the plug-in. 

void PluginEntry(void)
{
	REALRegisterMethod(&SetMoviePlayHintsMethod);
}

Class Extensions

Global methods are useful and easy to implement, but soon you will discover that they do not fill all of your REALbasic plug-in needs. Suppose, for example, that you wished to add some properties or methods to an existing REALbasic class. The REALbasic Plug-in SDK gives you the means to accomplish a task like this via a Class Extension.

To illustrate Class Extensions, we will add a new property to the MoviePlayer control to permit users to play every frame of a QuickTime movie. The properties are defined in Listing 4.

Listing 4: Define a Class Extension Property

MoviePlayerProperties
REALproperty MoviePlayerProperties[] = {
{ nil, "PlayEveryFrame", "Boolean", 0, (REALproc) GetPlayEveryFrame, (REALproc) SetPlayEveryFrame },
};

This defines a new Boolean property of the MoviePlayer called PlayEveryFrame. The “getter” function for the property is GetPlayEveryFrame, while its “setter” is SetPlayEveryFrame. Listing 5 shows the definition of the setter and getter functions for this new property.

Listing 5: MoviePlayer Class Extension Properties

GetPlayEveryFrame and SetPlayEveryFrame

Set and get the value of Class Extension’s Property with these two functions. 

static Boolean GetPlayEveryFrame(REALmoviePlayer instance, long param)
{
	Boolean everyFrame = false;
	MovieController thePlayer;
	
	thePlayer = REALgetMoviePlayerController(instance);
	MCDoAction
		(thePlayer, mcActionGetPlayEveryFrame, &everyFrame);
	
	return (everyFrame);
		
}

static void SetPlayEveryFrame(REALmoviePlayer instance, long param, Boolean state)
{
	
	MovieController thePlayer;
	
	thePlayer = REALgetMoviePlayerController(instance);
	if (state)
		MCDoAction
			(thePlayer, mcActionSetPlayEveryFrame, (QT::Ptr)true);
	else
		MCDoAction
			(thePlayer, mcActionSetPlayEveryFrame, (QT::Ptr)false);
	
}

Setter and getter functions for properties look like most C functions, but they have a few unique aspects that distinguish them from, say, a global method. First off, getter and setter functions for properties have two requisite parameters. In this example, they are:

REALmoviePlayer instance, long param

The first parameter is the class to which the control belongs. The second parameter (a long) is an extra variable for passing information around the plug-in. We do not use it in this example, but it is required in the function’s definition and prototype. The setter function has an additional parameter, which corresponds to the data type of the REALbasic property being added via the Class Extension.

With the properties declared and the setter/getter functions in place, the next step is to place them into a Class Extension Definition. Listing 6 illustrates the MoviePlayer Class Extension definition.

Listing 6: Defining a Class Extension

MoviePlayerExtension 
REALclassDefinition MoviePlayerExtension = {
	kCurrentREALControlVersion,
	"MoviePlayer",
	nil,
	0,
	0,
	nil,
	nil,
	MoviePlayerProperties,
	sizeof(MoviePlayerProperties) / sizeof(REALproperty),
};
 

A Class Extension uses a reference to a REALclassDefinition structure. The fields of this structure are shown in Listing 7. Each field is optional, but you need to include all fields up to and including the last one you want to use. In our Class Extension, we chose to stop after defining the MoviePlayerProperties, since we do not need any field beyond that.

Listing 7: REALclassDefinition Fields

	1. version the version of the plug-in architecture that the control was built under; 
		just pass the constant kCurrentREALControlVersion
	2. name: the name of the class as used in REALbasic 
	3. superName: the name of the class's superclass; 
		must be a built-in class or a plug-in class registered prior to this one 
    4. dataSize: the size of the custom data structure allocated for each object. 
		NOTE: this data structure must be the same size on all platforms 
		(use padding if necessary)! 
    5. forSystemUse: reserved (set to zero) 
    6. constructor: function to call to initialize your custom data 
    7. destructor: function to call to destroy your custom data 
    8. properties: a reference to the array of property declarations for the class 
    9. propertyCount: the number of properties for the class 
   10. methods: a reference to the array of method declarations for the class 
   11. methodCount: the number of method declarations for the class 
   12. events: a reference to the array of event declarations for the class 
   13. eventCount: the number of event declarations for the class 
   14. eventInstances: a reference to an array of event handlers for the class 
   15. eventInstanceCount: the number of event handlers there are 
   16. interfaces: a comma-delimited string of names of the interfaces 
		supported by this control 
   17. bindDescriptions: a reference to an array of binding descriptions for this control 
   18. bindDescriptionCount: the number of binding descriptions there are

Finally, register the Class Extension as you did with the global method earlier.

PluginEntry v2 
void PluginEntry(void)
{
	REALRegisterMethod(&SetMoviePlayHintsMethod);
	REALRegisterClassExtension(&MoviePlayerExtension);
}

Controls

Class Extensions are limited creatures. Since Class Extensions extend existing structures, you are not permitted to add custom data to them . Classes and Controls, on the other hand, are defined by you, so you can add as much custom data to them as desired. Since Classes and Controls are so closely related, we will limit our discussion to Controls. Any pointers you pick up about Controls will usually carry over to Classes.

To demonstrate how to create a REALbasic Control, we will build a simple viewer for displaying the various images one might fine in a multiple image file. QuickTime supports a few image file formats that allow multiple images in one file. Some of the more popular ones include Photoshop (.psd) and multi-page TIFF (.tif).

The first step is to create a data structure that will store the image being displayed by the control.

MultiImageData 
struct MultiImageData
{
	REALpicture 	theImage;
};

To make sure that the Control redraws correctly, we need to define a Behavior for the Control. The REALbasic Plug-in SDK lists all of the possible behaviors you might include, but we will only concern ourselves with one: redrawFunction, the third field in a Behavior structure. Simply name the function you will use to redraw the Control in the third field when defining the Control’s Behaviors.

MultiImageBehaviour
REALcontrolBehaviour MultiImageBehaviour = {
	nil,			 					// init the control
	nil,								// dispose
	MultiImageDraw	 		// redraw the control
};

Keep in mind that the MultiImageDraw function is responsible for drawing the Control while the REALbasic application runs as well as when it is displayed in a window in the IDE. In the IDE, we will fill in the Control with a blue color. During runtime, we will draw an image (if we have one loaded).

MultiImageDraw
static void MultiImageDraw(REALcontrolInstance instance)
{
	
	QT::Rect myRect;
	short myWidth,myHeight;
	RGBColor fillCol = {0,0,0};
		
	// get a reference to the control's data structure
	ControlData
		(MultiImageControl, instance, MultiImageData, data);
	
	// how big is the control?
	REALGetControlBounds(instance, &myRect);
	 		
	// if we are in the IDE, simply draw 
	// a blue box
	if (!REALinRuntime())
	{
		//fill in the control with blue 
		fillCol.red = 0;
		fillCol.green = 0;
		fillCol.blue = 65535;
		RGBForeColor(&fillCol);
		PaintRect(&myRect);
	}		
	else
	{
		//draw an image, if we are in the Runtime
		myWidth = myRect.right - myRect.left;
		myHeight = myRect.bottom - myRect.top;
		 		
		if (data->theImage)
		{
			REALDrawPicturePrimitive(data->theImage, &myRect, 0);
		}
	}
}

The Control will have two methods to tell us how many images are in a file and to draw a specific image in the Control. Define them as shown in Listing 8:

Listing 8: MultiImageControl Methods

MultiImageMethods, LoadImage, and ImageCountfunc
REALmethodDefinition MultiImageMethods[] = {
	{ (REALproc) LoadImage, REALnoImplementation, "LoadImageFile(FolderItem as FolderItem, pgNum as integer)"},
	{ (REALproc) ImageCountfunc, REALnoImplementation, "ImageCount(FolderItem as FolderItem) as integer" },
};

static void LoadImage
	(REALcontrolInstance instance, 
	REALfolderItem myRF, long pgNum)
{
	//get a reference to the control's data structure
	ControlData
		(MultiImageControl, instance, MultiImageData, data);
	
	int imgCount;
	imgCount = ImageCountfunc(instance, myRF);
	if ( imgCount > 0)
	{
		//get an image based on 1-based index 
		data->theImage = GetImageByIndexfunc(myRF, pgNum);

		//refresh the control's iamge
		MultiImageDraw(instance);

	}
	else
	{
		data->theImage = nil;
	}	
}


static int ImageCountfunc(REALcontrolInstance instance, REALfolderItem myRF)
	{
	//returns image count of a file 
		
		ComponentInstance 	gImporter;
		unsigned long			myCount;
		OSErr							myErr = QT::noErr;
		FSSpec							myFSpec;
	
		myCount = 0;
		ControlData
			(MultiImageControl, instance, MultiImageData, data);
		
		if (!REALFSSpecFromFolderItem(&myFSpec, myRF))
			return;

		myErr = GetGraphicsImporterForFile(&myFSpec, &gImporter);
		if (myErr != QT::noErr) return (myErr);
		myErr = GraphicsImportGetImageCount 
										(gImporter, &myCount);
		if (myErr != QT::noErr) return (32);
		
		if (gImporter != NULL)
			CloseComponent(gImporter);
		return myCount;
		
	}

You might have noticed that these Control functions have a parameter much like the Properties of the Class Extension presented earlier. This is required and gives you access to the instance of the control. This in turn permits you to access the Control’s data structure.

Next, define the control. Again, consult the SDK to see all the possible fields in the REALcontrol structure.

MultiImageControl
REALcontrol MultiImageControl = {
	kCurrentREALControlVersion,
	"MultiImageViewer",              // name of control
	sizeof(MultiImageData),
	0,	// for invisible controls, use: REALinvisibleControl
	128,				// PICT resource for toolbar 
	129,				// PICT resource for toolbar (depressed)
	320, 240,	// the default size of the control 
	nil,				// no properties this time...
	0,					// sizeof(properties)
	MultiImageMethods,	// the methods
	sizeof(MultiImageMethods) / sizeof(REALmethodDefinition),
	nil,				// the events
	0,					// sizeof(events)
	&MultiImageBehaviour
};

Finally, register the Control in the PluginEntry.

REALRegisterControl(&MultiImageControl);

The complete plug-in code is shown in Listing 9.

Listing 9: MacTechPlugin.cpp

// MacTechPlugin.cpp
// Demonstrates a simple REALbasic plug-in 
//
// Targets: Classic, Carbon
//
// REALbasic version used in demo: 4.0.2 
//
// CodeWarrior version used in demo: 6 - 
// Version 7 should also work without any project changes


#include "MacTechPlugin.h"


//**********************
//      GLOBAL METHOD
//**********************

static void SetMoviePlayHintsFunc
			( REALmovie theMovie, Boolean theState )
{
	QT::Movie aMovie;
	
	//get the QT movie from the REALmovie struct
	aMovie = REALgetMovieMovie( theMovie );
	
	//if we have a movie, set it's highQuality on/off
	if (aMovie)
	{
		if (theState)
			SetMoviePlayHints
				(aMovie, hintsHighQuality, hintsHighQuality);
		else
			SetMoviePlayHints(aMovie, 0, hintsHighQuality);
	}

}

//********************************************
//      CLASS EXTENSION - MoviePlayer
//********************************************

REALproperty MoviePlayerProperties[] = {
	{ nil, "PlayEveryFrame", "Boolean", 0, (REALproc) GetPlayEveryFrame, (REALproc) SetPlayEveryFrame },
};

static Boolean GetPlayEveryFrame(REALmoviePlayer instance, long param)
{
	Boolean everyFrame = false;
	MovieController thePlayer;
	
	thePlayer = REALgetMoviePlayerController(instance);
	MCDoAction
		(thePlayer, mcActionGetPlayEveryFrame, &everyFrame);
	
	return (everyFrame);
		
}

static void SetPlayEveryFrame(REALmoviePlayer instance, long param, Boolean state)
{
	
	MovieController thePlayer;
	
	thePlayer = REALgetMoviePlayerController(instance);
	if (state)
		MCDoAction
			(thePlayer, mcActionSetPlayEveryFrame, (QT::Ptr)true);
	else
		MCDoAction
			(thePlayer, mcActionSetPlayEveryFrame, (QT::Ptr)false);
	
}



//********************************************
//		CONTROL  - 	MultiImage viewer 
//		- for image files that might 
//		hold more than one image 
//		(.psd, .tif, etc...)
//********************************************

extern struct REALcontrol MultiImageControl;


struct MultiImageData
{
	REALpicture 	theImage;
};


static void MultiImageDraw(REALcontrolInstance instance)
{
	
	QT::Rect myRect;
	
	short myWidth,myHeight;
	RGBColor fillCol = {0,0,0};
		
	// get a reference to the control's data structure
	ControlData
		(MultiImageControl, instance, MultiImageData, data);
	
	// how big is the control?
	REALGetControlBounds(instance, &myRect);
	 		
	// if we are in the IDE, simply draw 
	// a blue box
	if (!REALinRuntime())
	{

		//fill in the control with blue 
		fillCol.red = 0;
		fillCol.green = 0;
		fillCol.blue = 65535;
		RGBForeColor(&fillCol);
		PaintRect(&myRect);

	}		
	else
	{
		//draw an image, if we are in the Runtime
		myWidth = myRect.right - myRect.left;
		myHeight = myRect.bottom - myRect.top;
		 		
		if (data->theImage)
		{
			REALDrawPicturePrimitive(data->theImage, &myRect, 0);
		}
	}
}

static void LoadImage(REALcontrolInstance instance, REALfolderItem myRF, long pgNum)
{
	//get a reference to the control's data structure
	ControlData
			(MultiImageControl, instance, MultiImageData, data);
	
	int imgCount;
	imgCount = ImageCountfunc(instance, myRF);
	if ( imgCount > 0)
	{
		//get an image based on 1-based index 
		data->theImage = GetImageByIndexfunc(myRF, pgNum);

		//refresh the control's iamge
		MultiImageDraw(instance);

	}
	else
	{
		data->theImage = nil;
	}	
}


//returns image count of a file 
static int ImageCountfunc(REALcontrolInstance instance, REALfolderItem myRF)
	{
		
		ComponentInstance 	gImporter;
		unsigned long				myCount;
		OSErr							myErr = QT::noErr;
		FSSpec							myFSpec;
	
		myCount = 0;

		ControlData
			(MultiImageControl, instance, MultiImageData, data);
		
		if (!REALFSSpecFromFolderItem(&myFSpec, myRF))
			return;

		myErr = GetGraphicsImporterForFile(&myFSpec, &gImporter);
		if (myErr != QT::noErr) return (myErr);
		myErr = GraphicsImportGetImageCount 
										(gImporter, &myCount);
		if (myErr != QT::noErr) return (32);
		
		if (gImporter != NULL)
			CloseComponent(gImporter);
		return myCount;
		
	}


//load an image into the control using 1-based index
static REALpicture GetImageByIndexfunc(REALfolderItem myRF, int indx)
	{
		
		ComponentInstance 	gImporter;
		QT::Rect						myRect;
		unsigned long				myCount, myIndex;
		OSErr							myErr = QT::noErr;
		OSErr							err = QT::noErr;
		FSSpec							myFSpec;
	
	if (!REALFSSpecFromFolderItem(&myFSpec, myRF))
		return;

		myErr = GetGraphicsImporterForFile(&myFSpec, &gImporter);
		if (myErr != QT::noErr) return (REALpicture)NULL;
		myErr = GraphicsImportGetImageCount 
												(gImporter, &myCount);
		if (myErr != QT::noErr) return (REALpicture)NULL;
		
		//loop through all of the layers
		//and look for the one we want
		//(i.e. indx)
		for (myIndex = 1; myIndex <= myCount; myIndex++) 
		{
			if (myIndex == indx)
			{
				myErr = GraphicsImportSetImageIndex
												(gImporter, myIndex);
				if (myErr!=QT::noErr) goto bail;
				GraphicsImportGetNaturalBounds(gImporter, &myRect);
				
				//Do the GWorld stuff
				GWorldPtr world;
				myErr = NewGWorld
									( &world, 8, &myRect, NULL, NULL, 0);
				if (err != QT::noErr) return (REALpicture)NULL;
				
				//set port and draw
				GraphicsImportSetGWorld 
									(gImporter, (CGrafPtr)world, NULL);
				GraphicsImportDraw(gImporter);
				
				if (gImporter != NULL)
					CloseComponent(gImporter);

				return (REALBuildPictureFromGWorld(world, true));
				
			}
			
		}
		
		bail:
		if (gImporter != NULL)
			CloseComponent(gImporter);
		return (REALpicture)NULL;
	}
	

REALclassDefinition MoviePlayerExtension = {
	kCurrentREALControlVersion,
	"MoviePlayer",
	nil,
	0,
	0,
	nil,
	nil,
	MoviePlayerProperties,
	sizeof(MoviePlayerProperties) / sizeof(REALproperty),
	nil,
	0,
	nil,
	0,
};

REALmethodDefinition MultiImageMethods[] = {
	{ (REALproc) LoadImage, REALnoImplementation, "LoadImageFile(FolderItem as FolderItem, pgNum as integer)" },
	{ (REALproc) ImageCountfunc, REALnoImplementation, "ImageCount(FolderItem as FolderItem) as integer" },
};


REALcontrolBehaviour MultiImageBehaviour = {
	nil,			 				// init the control
	nil,							// dispose
	MultiImageDraw	 	// redraw the control
};


REALcontrol MultiImageControl = {
	kCurrentREALControlVersion,
	"MultiImageViewer",        // name of control
	sizeof(MultiImageData),
	0,						
	128,				// PICT resource for toolbar 
	129,				// PICT resource for toolbar (depressed)
	320, 240,			// the default size of the control	nil,		
						// no properties this time...
	0,					// sizeof(properties)
	MultiImageMethods,	// the methods
	sizeof(MultiImageMethods) / sizeof(REALmethodDefinition),
	nil,				// the events
	0,					// sizeof(events)
	&MultiImageBehaviour
};


REALmethodDefinition SetMoviePlayHintsMethod = 
	{ (REALproc) SetMoviePlayHintsFunc, REALnoImplementation, "SetMoviePlayHints(theMovie as Movie, state as Boolean)" };


#pragma mark -
void PluginEntry(void)
{
	
	REALRegisterMethod(&SetMoviePlayHintsMethod);
	REALRegisterClassExtension(&MoviePlayerExtension);
	REALRegisterControl(&MultiImageControl);
	
}

Conclusion

This time we looked at how to build a REALbasic plug-in consisting of a global method, a Class Extension, and a Control. Although we only scratched the surface of plug-in possibilities, this at least gives you a good start for beginning plug-in development. Check the various resources listed in the bibliography if you need more help and above all, happy plugging!

Bibliography

The Internet provides the bulk of information about REALbasic plug-in development. Start at REAL Software’s site and download the latest SDK. Then, sign up for the REALbasic plug-in list. Many talented plug-in programmers frequent the lists and often provide valuable assistance.

REALsoftware
http://www.realsoftware.com
The mother ship... visit here often.

REALbasic Plug-in SDK
http://webster.realsoftware.com/download/release.html
Required visiting! The SDK provides all the files you need to get started programming REALbasic plug-ins.

REALbasic Plug-ins List
http://webster.realsoftware.com/support/internet.html
Need help? Join the REALbasic Plug-ins list and ask away!

Thomas Tempelmann
http://www.tempel.org/rb/index.html
Here you’ll find many great REALbasic plug-in code examples.

REALbasic Plugin Programming
Erick Tejkowski
http://www.mactech.com/articles/mactech/Vol.15/15.10/REALbasicPlugin/index.html
The original MacTech REALbasic plug-in article from 1999.

Erick Tejkowski is the author of REALbasic for Dummies. You can reach him at etejkowski@mac.com.

 
AAPL
$117.60
Apple Inc.
-1.03
MSFT
$47.47
Microsoft Corpora
-0.12
GOOG
$541.08
Google Inc.
+1.81

MacTech Search:
Community Search:

Software Updates via MacUpdate

MacUpdate Desktop 6.0.3 - Discover and i...
MacUpdate Desktop 6 brings seamless 1-click installs and version updates to your Mac. With a free MacUpdate account and MacUpdate Desktop 6, Mac users can now install almost any Mac app on macupdate.... Read more
SteerMouse 4.2.2 - Powerful third-party...
SteerMouse is an advanced driver for USB and Bluetooth mice. It also supports Apple Mighty Mouse very well. SteerMouse can assign various functions to buttons that Apple's software does not allow,... Read more
iMazing 1.1 - Complete iOS device manage...
iMazing (was DiskAid) is the ultimate iOS device manager with capabilities far beyond what iTunes offers. With iMazing and your iOS device (iPhone, iPad, or iPod), you can: Copy music to and from... Read more
PopChar X 7.0 - Floating window shows av...
PopChar X helps you get the most out of your font collection. With its crystal-clear interface, PopChar X provides a frustration-free way to access any font's special characters. Expanded... Read more
Carbon Copy Cloner 4.0.3 - Easy-to-use b...
Carbon Copy Cloner backups are better than ordinary backups. Suppose the unthinkable happens while you're under deadline to finish a project: your Mac is unresponsive and all you hear is an ominous,... Read more
ForeverSave 2.1.3 - Universal auto-save...
ForeverSave auto-saves all documents you're working on while simultaneously doing backup versioning in the background. Lost data can be quickly restored at any time. Losing data, caused by... Read more
Voila 3.8.1 - Capture, annotate, organiz...
Voila is a screen-capture, recording, and annotation tool that is a full-featured replacement for Mac's screen-capture and screen-recording capabilities. It has a large and robust set of editing,... Read more
SyncTwoFolders 2.0.6 - Syncs two user-sp...
SyncTwoFolders simply synchronizes two folders. It supports synchronization across mounted network drives and it is a possibility to run a simulation showing in a log what will be done. Please visit... Read more
Duplicate Annihilator 5.1.1 - Find and d...
Duplicate Annihilator takes on the time-consuming task of comparing the images in your iPhoto library using effective algorithms to make sure that no duplicate escapes. Duplicate Annihilator detects... Read more
HandBrake 0.10.0 - Versatile video encod...
HandBrake is a tool for converting video from nearly any format to a selection of modern, widely supported codecs. Supported Sources: VIDEO_TS folder, DVD image or real DVD (unencrypted -- CSS is... Read more

Latest Forum Discussions

See All

Tilt to Live Bundle Set to Arrive This T...
Tilt to Live Bundle Set to Arrive This Thanksgiving Posted by Ellis Spice on November 25th, 2014 [ permalink ] One Man Left has unveiled an upcoming Tilt to Live bundle, allowing players to get the series for a di | Read more »
BattleLore: Command (Entertainment)
BattleLore: Command 1.0 Device: iOS Universal Category: Entertainment Price: $9.99, Version: 1.0 (iTunes) Description: ***NOTE: Compatible with iPad 2/iPad mini, iPod touch 5 and up and iPhone 4S and up – WILL NOT RUN ON EARLIER... | Read more »
Weather Or Not Review
Weather Or Not Review By Jennifer Allen on November 25th, 2014 Our Rating: :: STYLISH WEATHER REPORTINGiPhone App - Designed for the iPhone, compatible with the iPad Check the weather quickly and conveniently with Weather or Not... | Read more »
The All-New Football Manager Handheld 20...
The All-New Football Manager Handheld 2015 is Available Now Posted by Jessica Fisher on November 25th, 2014 [ permalink ] Universal App - Designed for iPhone and iPad | Read more »
Six iOS Games to Get You Ready for Thank...
Image Source: Friends Wiki At this point in the month, you or at least a few people you know are probably getting ready to scramble around (or are already scrambling around) for Thanksgiving Dinner. It’s a hectic day of precise oven utilization, but... | Read more »
Call of Duty: Heroes: Tips, Tricks, and...
Hello Heroes: What’d we think of Call of Duty‘s take on Clash of Clans? Check out our Call of Duty: Heroes review to find out! Just downloaded Call of Duty: Heroes and need some handy tips and tricks on how to get ahead of the rest? As we often do,... | Read more »
Call of Duty: Heroes Review
Call of Duty: Heroes Review By Jennifer Allen on November 25th, 2014 Our Rating: :: CLASH OF FRANCHISESUniversal App - Designed for iPhone and iPad Mix Clash of Clans with Call of Duty, and this is what you get.   | Read more »
Slider Review
Slider Review By Jordan Minor on November 25th, 2014 Our Rating: :: SLIDE TO PLAYUniversal App - Designed for iPhone and iPad Slider has all the excitement of unlocking your phone screen.   | Read more »
oh my giraffe (Games)
oh my giraffe 1.0.0 Device: iOS Universal Category: Games Price: $1.99, Version: 1.0.0 (iTunes) Description: Eat fruits while being chased by lions. Cut the vines to send fruit plummeting onto the lions. Don't worry, your flexible... | Read more »
One of 2000’s Most Loves Adventure Games...
One of 2000’s Most Loves Adventure Games, The Longest Journey, has Come to iOS Posted by Jessica Fisher on November 25th, 2014 [ permalink ] | Read more »

Price Scanner via MacPrices.net

Early Black Friday MacBook Pro sale: 15-inch...
 Best Buy has posted early Black Friday prices on 15″ Retina MacBook Pros, with models on sale for $300 off MSRP on their online store for a limited time. Choose free local store pickup (if available... Read more
A9 Chips Already?
It’s barely more than a couple of months since Apple got the first A8 systems-on-chip into consumer hands, but rumor and news focus is already turning to the next-generation A9 SoC. Apple Daily... Read more
NewerTech Announces NuGuard KXs Impact X-Orbi...
NewerTech has announced updates to its family of Impact X-Orbing Screen Armor bringing military grade, triple layer protection to Apple’s new iPhone 6 and 6 Plus. Like all models in the NuGuard KXs... Read more
13-inch 1.4GHz MacBook Air on sale for $889,...
 B&H Photo has the 13″ 1.4GHz/128GB MacBook Air on sale for $889 including free shipping plus NY tax only. Their price is $110 off MSRP. B&H will also include free copies of Parallels Desktop... Read more
Save up to $300 on Macs and iPads with your A...
Purchase a new Mac or iPad at The Apple Store for Education and take up to $300 off MSRP. All teachers, students, and staff of any educational institution qualify for the discount. Shipping is free,... Read more
Apple refurbished Mac Pros available for up t...
The Apple Store is offering Apple Certified Refurbished Mac Pros for up to $600 off the cost of new models. An Apple one-year warranty is included with each Mac Pro, and shipping is free. The... Read more
Jumptuit Launches One-Tap Windows 8.1 iTunes...
Jumptuit has launched Windows 8.1 support for One-Tap iTunes Sync. with which Windows 8.1 users can now easily sync their iTunes libraries with Microsoft OneDrive. Jumptuit provides easy access from... Read more
Apple restocks refurbished 13-inch 2014 Retin...
The Apple Store has restocked Apple Certified Refurbished 2014 13″ 2.6GHz Retina MacBook Pros for up to $230 off the cost of new models. An Apple one-year warranty is included with each model, and... Read more
CEA Study Finds More People Recycling Electro...
A new study by the Consumer Electronics Association (CEA) finds that electronics recycling receives the continued and growing support of consumers. According to the CEA,s Recycling and Reuse Study,... Read more
15″ 2.2GHz Retina MacBook Pro on sale for $17...
 B&H Photo has the 2014 15″ 2.2GHz Retina MacBook Pro on sale today for $1749. Shipping is free, and B&H charges NY sales tax only. B&H will also include free copies of Parallels Desktop... Read more

Jobs Board

*Apple* Retail - Multiple Positions (US) - A...
Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, you're also the Read more
*Apple* Solutions Consultant (ASC) - Apple (...
**Job Summary** The ASC is an Apple employee who serves as an Apple brand ambassador and influencer in a Reseller's store. The ASC's role is to grow Apple Read more
*Apple* Solutions Consultant (ASC) - Apple (...
**Job Summary** The ASC is an Apple employee who serves as an Apple brand ambassador and influencer in a Reseller's store. The ASC's role is to grow Apple Read more
*Apple* Solutions Consultant (ASC)- Retail S...
**Job Summary** The ASC is an Apple employee who serves as an Apple brand ambassador and influencer in a Reseller's store. The ASC's role is to grow Apple Read more
Project Manager, *Apple* Financial Services...
**Job Summary** Apple Financial Services (AFS) offers consumers, businesses and educational institutions ways to finance Apple purchases. We work with national and Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.