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

Tokkun Studio unveils alpha trailer for...
We are back on the MMORPG news train, and this time it comes from the sort of international developers Tokkun Studio. They are based in France and Japan, so it counts. Anyway, semantics aside, they have released an alpha trailer for the upcoming... | Read more »
Win a host of exclusive in-game Honor of...
To celebrate its latest Jujutsu Kaisen crossover event, Honor of Kings is offering a bounty of login and achievement rewards kicking off the holiday season early. [Read more] | Read more »
Miraibo GO comes out swinging hard as it...
Having just launched what feels like yesterday, Dreamcube Studio is wasting no time adding events to their open-world survival Miraibo GO. Abyssal Souls arrives relatively in time for the spooky season and brings with it horrifying new partners to... | Read more »
Ditch the heavy binders and high price t...
As fun as the real-world equivalent and the very old Game Boy version are, the Pokemon Trading Card games have historically been received poorly on mobile. It is a very strange and confusing trend, but one that The Pokemon Company is determined to... | Read more »
Peace amongst mobile gamers is now shatt...
Some of the crazy folk tales from gaming have undoubtedly come from the EVE universe. Stories of spying, betrayal, and epic battles have entered history, and now the franchise expands as CCP Games launches EVE Galaxy Conquest, a free-to-play 4x... | Read more »
Lord of Nazarick, the turn-based RPG bas...
Crunchyroll and A PLUS JAPAN have just confirmed that Lord of Nazarick, their turn-based RPG based on the popular OVERLORD anime, is now available for iOS and Android. Starting today at 2PM CET, fans can download the game from Google Play and the... | Read more »
Digital Extremes' recent Devstream...
If you are anything like me you are impatiently waiting for Warframe: 1999 whilst simultaneously cursing the fact Excalibur Prime is permanently Vault locked. To keep us fed during our wait, Digital Extremes hosted a Double Devstream to dish out a... | Read more »
The Frozen Canvas adds a splash of colou...
It is time to grab your gloves and layer up, as Torchlight: Infinite is diving into the frozen tundra in its sixth season. The Frozen Canvas is a colourful new update that brings a stylish flair to the Netherrealm and puts creativity in the... | Read more »
Back When AOL WAS the Internet – The Tou...
In Episode 606 of The TouchArcade Show we kick things off talking about my plans for this weekend, which has resulted in this week’s show being a bit shorter than normal. We also go over some more updates on our Patreon situation, which has been... | Read more »
Creative Assembly's latest mobile p...
The Total War series has been slowly trickling onto mobile, which is a fantastic thing because most, if not all, of them are incredibly great fun. Creative Assembly's latest to get the Feral Interactive treatment into portable form is Total War:... | Read more »

Price Scanner via MacPrices.net

Early Black Friday Deal: Apple’s newly upgrad...
Amazon has Apple 13″ MacBook Airs with M2 CPUs and 16GB of RAM on early Black Friday sale for $200 off MSRP, only $799. Their prices are the lowest currently available for these newly upgraded 13″ M2... Read more
13-inch 8GB M2 MacBook Airs for $749, $250 of...
Best Buy has Apple 13″ MacBook Airs with M2 CPUs and 8GB of RAM in stock and on sale on their online store for $250 off MSRP. Prices start at $749. Their prices are the lowest currently available for... Read more
Amazon is offering an early Black Friday $100...
Amazon is offering early Black Friday discounts on Apple’s new 2024 WiFi iPad minis ranging up to $100 off MSRP, each with free shipping. These are the lowest prices available for new minis anywhere... Read more
Price Drop! Clearance 14-inch M3 MacBook Pros...
Best Buy is offering a $500 discount on clearance 14″ M3 MacBook Pros on their online store this week with prices available starting at only $1099. Prices valid for online orders only, in-store... Read more
Apple AirPods Pro with USB-C on early Black F...
A couple of Apple retailers are offering $70 (28%) discounts on Apple’s AirPods Pro with USB-C (and hearing aid capabilities) this weekend. These are early AirPods Black Friday discounts if you’re... Read more
Price drop! 13-inch M3 MacBook Airs now avail...
With yesterday’s across-the-board MacBook Air upgrade to 16GB of RAM standard, Apple has dropped prices on clearance 13″ 8GB M3 MacBook Airs, Certified Refurbished, to a new low starting at only $829... Read more
Price drop! Apple 15-inch M3 MacBook Airs now...
With yesterday’s release of 15-inch M3 MacBook Airs with 16GB of RAM standard, Apple has dropped prices on clearance Certified Refurbished 15″ 8GB M3 MacBook Airs to a new low starting at only $999.... Read more
Apple has clearance 15-inch M2 MacBook Airs a...
Apple has clearance, Certified Refurbished, 15″ M2 MacBook Airs now available starting at $929 and ranging up to $410 off original MSRP. These are the cheapest 15″ MacBook Airs for sale today at... Read more
Apple drops prices on 13-inch M2 MacBook Airs...
Apple has dropped prices on 13″ M2 MacBook Airs to a new low of only $749 in their Certified Refurbished store. These are the cheapest M2-powered MacBooks for sale at Apple. Apple’s one-year warranty... Read more
Clearance 13-inch M1 MacBook Airs available a...
Apple has clearance 13″ M1 MacBook Airs, Certified Refurbished, now available for $679 for 8-Core CPU/7-Core GPU/256GB models. Apple’s one-year warranty is included, shipping is free, and each... Read more

Jobs Board

Seasonal Cashier - *Apple* Blossom Mall - J...
Seasonal Cashier - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
Seasonal Fine Jewelry Commission Associate -...
…Fine Jewelry Commission Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) Read more
Seasonal Operations Associate - *Apple* Blo...
Seasonal Operations Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Read more
Hair Stylist - *Apple* Blossom Mall - JCPen...
Hair Stylist - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Blossom 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
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.