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.

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Latest Forum Discussions

See All

Jump into one of Volkswagen's most...
We spoke about PUBG Mobile yesterday and their Esports development, so it is a little early to revisit them, but we have to because this is just too amusing. Someone needs to tell Krafton that PUBG Mobile is a massive title because out of all the... | Read more »
PUBG Mobile will be releasing more ways...
The emergence of Esports is perhaps one of the best things to happen in gaming. It shows our little hobby can be a serious thing, gets more people intrigued, and allows players to use their skills to earn money. And on that last point, PUBG Mobile... | Read more »
Genshin Impact 5.1 launches October 9th...
If you played version 5.0 of Genshin Impact, you would probably be a bit bummed by the lack of a Pyro version of the Traveller. Well, annoyingly HoYo has stopped short of officially announcing them in 5.1 outside a possible sighting in livestream... | Read more »
A Phoenix from the Ashes – The TouchArca...
Hello! We are still in a transitional phase of moving the podcast entirely to our Patreon, but in the meantime the only way we can get the show’s feed pushed out to where it needs to go is to post it to the website. However, the wheels are in motion... | Read more »
Race with the power of the gods as KartR...
I have mentioned it before, somewhere in the aether, but I love mythology. Primarily Norse, but I will take whatever you have. Recently KartRider Rush+ took on the Arthurian legends, a great piece of British mythology, and now they have moved on... | Read more »
Tackle some terrifying bosses in a new g...
Blue Archive has recently released its latest update, packed with quite an arsenal of content. Named Rowdy and Cheery, you will take part in an all-new game mode, recruit two new students, and follow the team's adventures in Hyakkiyako. [Read... | Read more »
Embrace a peaceful life in Middle-Earth...
The Lord of the Rings series shows us what happens to enterprising Hobbits such as Frodo, Bilbo, Sam, Merry and Pippin if they don’t stay in their lane and decide to leave the Shire. It looks bloody dangerous, which is why September 23rd is an... | Read more »
Athena Crisis launches on all platforms...
Athena Crisis is a game I have been following during its development, and not just because of its brilliant marketing genius of letting you play a level on the webpage. Well for me, and I assume many of you, the wait is over as Athena Crisis has... | Read more »
Victrix Pro BFG Tekken 8 Rage Art Editio...
For our last full controller review on TouchArcade, I’ve been using the Victrix Pro BFG Tekken 8 Rage Art Edition for PC and PlayStation across my Steam Deck, PS5, and PS4 Pro for over a month now. | Read more »
Matchday Champions celebrates early acce...
Since colossally shooting themselves in the foot with a bazooka and fumbling their deal with EA Sports, FIFA is no doubt scrambling for other games to plaster its name on to cover the financial blackhole they made themselves. Enter Matchday, with... | Read more »

Price Scanner via MacPrices.net

Apple Watch Ultra available today at Apple fo...
Apple has several Certified Refurbished Apple Watch Ultra models available in their online store for $589, or $210 off original MSRP. Each Watch includes Apple’s standard one-year warranty, a new... Read more
Amazon is offering coupons worth up to $109 o...
Amazon is offering clippable coupons worth up to $109 off MSRP on certain Silver and Blue M3-powered 24″ iMacs, each including free shipping. With the coupons, these iMacs are $150-$200 off Apple’s... Read more
Amazon is offering coupons to take up to $50...
Amazon has Apple’s M2-powered Mac minis in stock and on sale for up to $110 off MSRP, each including free delivery. Prices are valid after free coupons available on each mini’s product page, detailed... Read more
Use your Education discount to take up to $10...
Need a new Apple iPad? If you’re a student, teacher, or staff member at any educational institution, you can use your .edu email address when ordering at Apple Education to take up to $100 off the... Read more
Apple has 15-inch M2 MacBook Airs available f...
Apple has clearance, Certified Refurbished, 15″ M2 MacBook Airs available starting at $1019 and ranging up to $300 off original MSRP. These are the cheapest 15″ MacBook Airs for sale today at Apple.... Read more
Mac Studio with M2 Max CPU on sale for $1749,...
B&H Photo has the standard-configuration Mac Studio model with Apple’s M2 Max CPU in stock today and on sale for $250 off MSRP, now $1749 (12-Core CPU and 32GB RAM/512GB SSD). B&H offers... Read more
Save up to $260 on a 15-inch M3 MacBook Pro w...
Apple has Certified Refurbished 15″ M3 MacBook Airs in stock today starting at only $1099 and ranging up to $260 off MSRP. These are the cheapest M3-powered 15″ MacBook Airs for sale today at Apple.... Read more
Apple has 16-inch M3 Pro MacBook Pro in stock...
Apple has a full line of 16″ M3 Pro MacBook Pros available, Certified Refurbished, starting at $2119 and ranging up to $440 off MSRP. Each model features a new outer case, shipping is free, and an... Read more
Apple M2 Mac minis on sale for $120-$200 off...
Amazon has Apple’s M2-powered Mac minis in stock and on sale for $110-$200 off MSRP this weekend, each including free delivery: – Mac mini M2/256GB SSD: $469, save $130 – Mac mini M2/512GB SSD: $689.... Read more
Clearance 9th-generation iPads are in stock t...
Best Buy has Apple’s 9th generation 10.2″ WiFi iPads on clearance sale for starting at only $199 on their online store for a limited time. Sale prices for online orders only, in-store prices may vary... Read more

Jobs Board

Senior Mobile Engineer-Android/ *Apple* - Ge...
…Trust/Other Required:** NACI (T1) **Job Family:** Systems Engineering **Skills:** Apple Devices,Device Management,Mobile Device Management (MDM) **Experience:** 10 + Read more
Sonographer - *Apple* Hill Imaging Center -...
Sonographer - Apple Hill Imaging Center - Evenings Location: York Hospital, York, PA Schedule: Full Time Full Time (80 hrs/pay period) Evenings General Summary Read more
*Apple* Systems Administrator - JAMF - Activ...
…**Public Trust/Other Required:** None **Job Family:** Systems Administration **Skills:** Apple Platforms,Computer Servers,Jamf Pro **Experience:** 3 + years of Read more
Cashier - *Apple* Blossom Mall - JCPenney (...
Cashier - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Blossom Mall Read more
Omnichannel Associate - *Apple* Blossom Mal...
Omnichannel Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.