Infenro Home SDK Docs Blah

InfernoCommon

Declared in:/boot/home/devel/Inferno-project/Inferno/SDK/Headers/Core/InfernoCommon.h
Author: YNOP
Version:1.0
Date: Feb 5 2000
Summary:more...




Hook Functions


InfernoCommon()
InfernoCommon()

The Inferno Common pointer ( ICommon ) gets passed to all plug-ins. This means that all plug-ins have access to the methods of InfernoCommon. This class provides all common interfacing to the core.


~InfernoCommon()
~InfernoCommon()

UpdateCanvas()
void UpdateCanvas(BRect dirtyRect)

Using the UpdateCanvas() without a parameter, will update the whole canvas at once


UpdateCanvas()
void UpdateCanvas()

Using the UpdateCanvas() without a parameter, will update the whole canvas at once


GetFgColor()
rgb_color GetFgColor()

Gets the current Forground color


GetBgColor()
rgb_color GetBgColor()

Gets the current Background color


SetFgColor()
void SetFgColor(rgb_color c)

Sets the forground color from pram list

Broadcasts a I_COLOR_CHANGED message


SetBgColor()
void SetBgColor(rgb_color c)

Sets the background color from pram list

Broadcasts a I_COLOR_CHANGED message


SetFgColor()
void SetFgColor(uint8 r,uint8 g, uint8 b, uint8 a)

Sets the forground color from pram list

Broadcasts a I_COLOR_CHANGED message


SetBgColor()
void SetBgColor(uint8 r,uint8 g, uint8 b, uint8 a)

Sets the background color from pram list

Broadcasts a I_COLOR_CHANGED message


SetZoom()
void SetZoom(int32 precent = 100)

Set the zoom level for the currnet document in terms of precent.

Broadcasts a I_COMMON_CHANGED message


GetZoom()
int32 GetZoom()

returns the precent zoom


GetBrush()
IBrush* GetBrush()

Returns a pointer to IBrush pointer Inferno stores a common brush and a common pattern for the user. This makes it possible to have a global brush that works in all plug-ins. This avoids having to add code for brush-slection to all plug-ins. This also goes for the patterns (which are just plain tiled imaged at this moment). Due this convention, it is possible to have all standart plug-ins that use the Bitmap Tools, paint with the current pattern.

The definition of the Inferno Brush is as follows:



   struct IBrush{
      BBitmap *brush;
      BPoint center;
      int32 mode;
      int32 stepping; // percentage of stepping (1 to 100) 
   };


The BBitmap use for the brush needs to be a B_RGB32 bitmap. We use this convention to be able to have stamps too. The intensity of the pixels is used as transparency. Black is opaque, white is full transparant. The center-point is not used for the common brush fuctions, this is also provided for stamps.The mode parameter is a global value for the drawmode presented to you in the bitmap tools. It is not required to use it. You can also add a draw-mode menu to the plug-ins. Stepping, is the distance in percents of one brush stroke to another. The most common used value is 25%


SetBrush()
void SetBrush(IBrush *b)

Sets the brush

Broadcasts a I_BRUSH_CHANGED message


GetPattern()
BBitmap* GetPattern()

Gets the currnet pattern. Currnetly patterns are simple BBitmaps. This may change in the future


SetPattern()
void SetPattern(BBitmap *pat)

Set the currnet pattern

Broadcasts a I_PATTERN_CHANGED message


GetGradient()
Gradient* GetGradient()

Gets the gradient


SetGradient()
void SetGradient(Gradient *g)

Set the currnet pattern

Broadcasts a I_GRADIENT_CHANGED message


SetStatus()
void SetStatus(... ...st char *format,...)

Sets the text of the status bar (the bar at the bottom of the current project window)


UpdateProgress()
void UpdateProgress(int32 precent)

Setting the ProgressBar that shows on the right-bottom of the Inferno Document window:



   ICommon->SetProgress( 75 ); // sets the progress bar to 75%


When done with your work, you need to set the progressbar to 0, to dissable i


CreateLayerOfType()
InfernoLayer* CreateLayerOfType(const char *type,BMessage* initmsg)

Provids a way for you to creat a new layer of type with a initmessage. Inferno will instantiate the plugin and pass you initmsg diectly to the layers InfernoLayer::Init() method

If you add the layer to a Document then the Doc takes responcibility for the memory. If not however you must delete it yourself.

In most cases type "Bitmap" will be used.


GetInstalledLayerTypes()
BList* GetInstalledLayerTypes()

Returns you a list of all the currently installed layer types (as a list of char)


AddLayer()
status_t AddLayer(InfernoLayer *ILay, int32 i = -1)

Adds a layer to the current document at a particular location. Location defaults to -1 which represents the Currnt location within the layer stack


SendMessage()
void SendMessage(const char *name,BMessage *msg)

Send a Message (msg) to a named target.

The targets INFERNO_APP, BROADCAST are defined for you. Broadcast will send the message to ALL tools, floaters, document, and Inferno itself.


GetLanguageKey()
char* GetLanguageKey(const char *key)

Inferno uses the YLanguage class which can be found on BeBits. This class provides a way to have multi- language applications by the use of key-files. The key-files that are used by Inferno are located in the Inferno/Laguages directory, and named after the language the represent.

A language file is build of keys. The keys are upper-case names for a word, frase or sentence. When using the key in Inferno, it gets replaced with the text that is noted behind that:

Language file:

TEST_KEY = "This is just a test key" FOUND = "Found what you're looking for!\n" OK = "Ok" ...

When you want to use a key, just use the ICommon method GetLanguageKey() as follows:



 printf( ICommon->GetLanguageKey( "FOUND"));


This code snipped outputs: Found what you're looking for!


Log()
void Log(... ...st char *format,...)

Dumps the string message to the inferno log file (in /tmp) This should be used when your plugin runs into some error.


AddTip()
void AddTip(BView *v, const char * tip = NULL)

Adds a Tool Tip to a view of your choice calling with a NULL tip will remove any previous tip. Tool tips can be enabled/disabled by the user so dont rely on them for getting info to the user


InstallDropHandler()
void InstallDropHandler(const char * mime,BLooper *target, const char *name)

Installs a drop handler for infenro.

Mime is a BeOS File type that Inferno will use to identify items that are dropped (if its a jpeg file then the mime would be 'image/jpeg'") Note that you can install DH for mime super types (ie 'image').

The looper (most commonly) will by yourself (this) as the target for the drop. Inferno will pass the drop message off to target and it become responcible for handling it.

Name is a unique name for what action will be preformed by this DHandler.

Inferno core installs a handler for 'image' You can install multiple handlers with the same mime type, and inferno will present the user with a list of action that are posible. This is why name is important as a unique discriber

Example:
A plain/text drop would most likely be handled by the TextLayer InstallDropHandler("plain/text",this,"Create TextLayer")


InstallCMSReqester()
void InstallCMSReqester(const char *name)

Installs a new requester type for CMSs Display and Printer are built in (see #define types)

Use this is you have special needs (from a scanner or from digital camra or such)


CMSTransform()
status_t CMSTransform(const char *name,BBitmap *bmap, BRect clip)

Transforms a rgb_color by useing the CMS bound to requeter name. Will return B_OK if everthing went ok. newcol should NOT be NULL


CMSTransform()
status_t CMSTransform(const char *name, rgb_color col, rgb_color *newcol)

Transforms a rgb_color by useing the CMS bound to requeter name. Will return B_OK if everthing went ok. newcol should NOT be NULL



Class Constants
Name Description
I_COMMON_CHANGED Common changed control msg
INFERNO_APP App target for SendMessage
BROADCAST Broadcast to all tools/floaters and Infenro
I_COLOR_CHANGED Message sent out on color changes
I_BRUSH_CHANGED Message sent out when the bursh changes
I_PATTERN_CHANGED Message sent out when the pattern changes
I_GRADIENT_CHANGED Message sent out when the gradient changes
DISPLAY_CMS Default CMS requester for Screen Display
PRINTER_CMS Default CMS requester for internal Printing

Infenro Home SDK Docs Blah

Generated on 12/27/2001
Copyright © 1999-2001 Inferno Dev Team. All rights reserved.