Copyright (c) Hyperion Entertainment and contributors.
Difference between revisions of "BOOPSI Images"
Steven Solie (talk | contribs) (Created page with "== Introduction == BOOPSI's imageclass is one of the standard classes built into Intuition. As its name implies, it is a class of Intuition Images. These BOOPSI images can be...") |
Steven Solie (talk | contribs) |
||
Line 5: | Line 5: | ||
== BOOPSI Image Methods == |
== BOOPSI Image Methods == |
||
− | Imageclass defines several methods of its own which subclasses of imageclass either have to implement or pass on to their superclass. The method IDs for imageclass are defined in <intuition/imageclass.h>. Each method requires some parameters |
+ | Imageclass defines several methods of its own which subclasses of imageclass either have to implement or pass on to their superclass. The method IDs for imageclass are defined in <intuition/imageclass.h>. Each method requires some parameters. |
{| class="wikitable" |
{| class="wikitable" |
||
Line 34: | Line 34: | ||
| IM_EXTENTFRAME || Inquire about rendering extent with dimensions. |
| IM_EXTENTFRAME || Inquire about rendering extent with dimensions. |
||
|} |
|} |
||
+ | |||
+ | The formats of each of these BOOPSI messages all differ. The MethodID is the only parameter common to each method. |
||
+ | |||
+ | === IM_DRAW === |
||
+ | |||
+ | The IM_DRAW method is used to tell the image to render itself. The Intuition function DrawImageState() uses this method. IM_DRAW receives the following parameters: |
||
+ | |||
+ | <syntaxhighlight> |
||
+ | struct impDraw |
||
+ | { |
||
+ | uint32 MethodID; |
||
+ | struct RastPort *imp_RPort; |
||
+ | struct |
||
+ | { |
||
+ | int16 X; |
||
+ | int16 Y; |
||
+ | } imp_Offset; |
||
+ | |||
+ | uint32 imp_State; |
||
+ | struct DrawInfo *imp_DrInfo; |
||
+ | }; |
||
+ | </syntaxhighlight> |
||
+ | |||
+ | The imp_State field contains the visual state to render the image. The visual states (defined in <intuition/imageclass.h>) are: |
||
+ | |||
+ | {| class="wikitable" |
||
+ | | IDS_NORMAL || idle state |
||
+ | |- |
||
+ | | IDS_SELECTED || for selected gadgets. |
||
+ | |- |
||
+ | | IDS_DISABLED || for disabled gadgets. |
||
+ | |- |
||
+ | | IDS_BUSY || for future functionality |
||
+ | |- |
||
+ | | IDS_INDETERMINATE || for future functionality |
||
+ | |- |
||
+ | | IDS_INACTIVENORMAL || normal, in inactive window border. |
||
+ | |- |
||
+ | | IDS_INACTIVESELECTED || selected, in inactive border. |
||
+ | |- |
||
+ | | IDS_INACTIVEDISABLED || disabled, in inactive border. |
||
+ | |} |
||
+ | |||
+ | When setting the pens to render an image, use the values from the imp_DrInfo->dri_Pens pen array (Note that it is possible that imp_DrInfo will be NULL). The possible pen values are defined in <intuition/screens.h>. |
||
+ | |||
+ | The following code fragment shows how to use the shadow color for rendering. |
||
+ | |||
+ | <syntaxhighlight> |
||
+ | uint16 *pens = (imp->imp_DrInfo) ? imp->imp_DrInfo->dri_Pens : NULL; |
||
+ | |||
+ | if (pens) |
||
+ | { |
||
+ | IIntuition->SetAPen (imp->imp_RPort, pens[SHADOWPEN]); |
||
+ | } |
||
+ | </syntaxhighlight> |
Revision as of 22:23, 5 April 2013
Introduction
BOOPSI's imageclass is one of the standard classes built into Intuition. As its name implies, it is a class of Intuition Images. These BOOPSI images can be used in place of traditional Image structure (as they contain an Intuition Image structure), but they are much more powerful. By using BOOPSI methods, an application or Intuition can tell an imageclass object to render itself. Because it renders itself (rather than Intuition rendering it), the imageclass object is free to render whatever it wants (well, within reason). For example, a BOOPSI image object can render itself according to the current display resolution, or to scale itself to any size an application requests.
BOOPSI Image Methods
Imageclass defines several methods of its own which subclasses of imageclass either have to implement or pass on to their superclass. The method IDs for imageclass are defined in <intuition/imageclass.h>. Each method requires some parameters.
Method | Description |
---|---|
IM_DRAW | Draw image with state. |
IM_DRAWFRAME | Draw image within frame limits. |
IM_ERASE | Erase image with state. |
IM_ERASEFRAME | Erase image within frame. |
IM_HITFRAME | Determine if image was hit within frame. |
IM_HITTEST | Determine if image was hit. |
The following methods are described at the imageclass level although it's up to the subclasses to actually implement them. If a class does not implement these methods it should either return zero, indicating that this class does not support the method, or defer processing on to its superclass.
Method | Description |
---|---|
IM_FRAMEBOX | Get recommended frame around some box. |
IM_EXTENT | Inquire about rendering extent. |
IM_EXTENTFRAME | Inquire about rendering extent with dimensions. |
The formats of each of these BOOPSI messages all differ. The MethodID is the only parameter common to each method.
IM_DRAW
The IM_DRAW method is used to tell the image to render itself. The Intuition function DrawImageState() uses this method. IM_DRAW receives the following parameters:
struct impDraw { uint32 MethodID; struct RastPort *imp_RPort; struct { int16 X; int16 Y; } imp_Offset; uint32 imp_State; struct DrawInfo *imp_DrInfo; };
The imp_State field contains the visual state to render the image. The visual states (defined in <intuition/imageclass.h>) are:
IDS_NORMAL | idle state |
IDS_SELECTED | for selected gadgets. |
IDS_DISABLED | for disabled gadgets. |
IDS_BUSY | for future functionality |
IDS_INDETERMINATE | for future functionality |
IDS_INACTIVENORMAL | normal, in inactive window border. |
IDS_INACTIVESELECTED | selected, in inactive border. |
IDS_INACTIVEDISABLED | disabled, in inactive border. |
When setting the pens to render an image, use the values from the imp_DrInfo->dri_Pens pen array (Note that it is possible that imp_DrInfo will be NULL). The possible pen values are defined in <intuition/screens.h>.
The following code fragment shows how to use the shadow color for rendering.
uint16 *pens = (imp->imp_DrInfo) ? imp->imp_DrInfo->dri_Pens : NULL; if (pens) { IIntuition->SetAPen (imp->imp_RPort, pens[SHADOWPEN]); }