As I told in users guide section, JumboPalette (JP) is a creature used
to choice, manage and edit palettes (gradations). Usually, it serves as
a part of other programs.When some program requires user-defined palettes
(example - visualisation kits), it can use JP to let user to choice them.
In its own, JP is a complete separate component which interacts with user
and performs palette-selection task.
Programmer: Pavel Vasev
If you have any questions or comments please email them to Pavel Vasev at contact@mail.ur.ru |
Ok, I suppose that you saw users guide for JP.
Now its time to speak about how to use it in your applications.
These topics are discussed here:
For now, JD/JP is only available as a component
for Delphi 5. Probably, it will work with earlier versions. I'm
going to create C-compatible dll and VisualC++ versions.
Please don't be confused of component name: "JumboDialog/JumboPalette". JumboPalette is a name of user-interface implementation, while JumboDialog is a name of Delphi component interface - together they form "JD/JP". I want to notify you, that this component is PostCard-Ware. If you enjoy it and you use it in your applications, please send a postcard of your town to: Pavel Vasev
|
I suppose that you already looked at "working with JumboPalette" topic
in users guide. Lets color is defined by 32-bit integer in '0RGB'
mode, where B is a lower byte. Then, palette is an array of so represented
colors. All palettes in JD/JP have fixed size, defined before JD/JP
is initialized. So, global palette size is a meaningful constant
when working with JD/JP. Palette folder(PF) is an array of palettes.
All palettes in all palette folders are same-sized. Each palette folder
is stored in external bmp file, and all these *.bmp are stored in
fixed directory. Each palette folder is stored in bmp as follows:
When JD/JP is deinitialized, is saves all PF as bmp files to PF-directory in 32color-depth format. When you call JD/JP, it executes modal dialog which interacts with user and allows him to select a palette, manage or create palettes. If user choiced a palette to activate (e.g. pressed ok button), you will have an access to this palette. Totally, you can:
|
This version of JD/JP component includes no separate
installation program. Therefore you have to copy all the files from "\DelphiSource\"
directory located in the supplied Zip-File at first in a directory of your
will.
You will have to add the JD/JP component, to the component library before you can use it; to do that, install "JumboDialog.pas". After installation, the "JumboDialog" button will appear at "Dialogs" page. Ok, now you are ready to look at topics below. |
The technique is as follows. When you install
JD/JP, you will recieve TJumboDialog class. Put it into your form class
using design manager. Then, set the design-time properties as you need.
The main are
PalettePath - a path to palette folder's bmp files, usualy relative like "Palettes\" (default) PaletteSize - a palette size you want to use. JD/JP assume this palsize in all palette operations. So you will work with palettes as with arrays of PaletteSize integers. Default 1024. MaxRecentCount specifies the number of palettes that 'Recents' folder holds. Default 32. bShowToolz specifies the mode in which JP is shown initially - user or enchanced. Default true. Ok. How to activate JP? As TJumboDialog is a child of TCommonDialog, you simply call Execute method. It returns true if user selected a palette, or false if he cancelled. Also, there is a UserOK property = true if user selected a palette after last execute call. Idea is as follows. Call Execute method. Check if the user confirmed his selection - Execute returns True, or UserOK property is True. Then retrieve selection by properties like 'ResultPtr' or 'Recent[0]'. Scale palette if necessary using methods like 'DupResult' or 'ScalePalette'. Draw recent palettes using 'RecentCount' and 'Recent[i]'. Use recieved palettes as an arrays of integers of PaletteSize-size each. Lets look at this example:
Here we used 2 internal helpers:
Ok, another example:
procedure TForm1.Button1Click(Sender: TObject);
procedure TForm1.FormPaint(Sender: TObject);
Ok, dont know what to add anymore. Description of all the functions, methods and properties you will find below. |
As I told, you can manipulate on palette folders
and add your own tools.
This topic will be described later by request (email). |
Non-class helpers:
function _rgbflip( c : integer ) : integer; //flips 0RGB to 0BGR for GDI usage type //for easy type-casting TPalette = array [0..$FFFF] of integer; PPalette = ^TPalette; public
property ResultPtr :
pointer;
function Execute: Boolean;
function StoreResult( dest
: pointer ) : boolean;
procedure ScalePalette(
source,dest : pointer; src_width,dest_width : integer; flipRGB : boolean
);
function ScaleResult( dest
: pointer; dest_width : integer; flipRGB : boolean ) : boolean;
function DupPalette( pal
: ppalette; original_dest : pointer; destwidth : integer; flipRGB : boolean
) : pointer;
function DupRecent( recent_index : integer;
original_dest : pointer; destwidth : integer; flipRGB : boolean ) : pointer;
procedure Restart;
published
// ADVANCHED SECTION
property JumboUserToolz : TCoolBar; procedure ActivateToolOptions( your_options : TWinControl; title : string ); {this routines works with the
items of __PalList}
function GetActivePalette :
PPalette;
{Palette Folder = PF. Each
PF, when saved, is just a bmp in _PalettePath_ directory}
function GetFolderID( FolderName
: string ) : integer;
function CreateNewFolder( DesiredFolderName
: string ) : integer;
procedure AddToFolder( folder_id : integer;
p : Pointer );
function GetFolderSize( folder_id
: integer ) : integer;
|
Here I end this document. It will be completed
later.
Be happy!
Created by Contact, july 2001
contact@mail.ur.ru