On 3/5/10 1:22 PM, eric b wrote:
Add the necessary png files to default_images in the appropriate
directory (probably svx/res or nowadays cui/res).


Was done since a while : if I'm not too wrong, the name of the .png is
in the .src, and when the .src are parsed, e.g. in svx, an
svx$LOCALE.ilst (for image list ?) is created in the unx..pro, and
delivered.

At the end, the .zip is created in the packimage and the .png exists.

Yes, that's how it currently works.

Currently I added two .png: one is padlock_open.png and the second is
obviously padlock_closed.png (or a name close to that), and both are found.

good :-)


What I did :

1) in .src

declare a color mask :

#define MASKCOLOR MaskColor = \
Color { Red = 0xFFFF ; Green = 0x0000 ; Blue = 0xFFFF ; };

You can probably skip the mask color (unless your PNG files actually contain magenta where the mask should be). Nowadays png files with alpha mask work just fine.

2) in the modaldialog, I added two ImageButton entries : one for every .png

e.g. :

ImageButton IMAGE_PADLOCK_OPEN
{
Pos = MAP_APPFONT ( (COL_3 + COL_4 )/2 + 5, ROW_3 - 20 ) ;
Size = MAP_APPFONT ( 16 , 16 ) ;
TabStop = TRUE ;
QuickHelpText [ en-US ] = "Click to lock" ;
QuickHelpText [ fr ] = "Cliquer pour verrouiller" ;
ButtonImage = Image
{
ImageBitmap = Bitmap
{
File = "Padlock1_open.png";
};
MASKCOLOR
};
};


In treeopt.cxx, I added in the INI_LIST ( used in the
OfaTreeOptionsDialog ctor), the
following initilization: aPadlockImageButton ( this, SVX_RES(
IMAGE_PADLOCK_OPEN ) ),\

+ I added the method loadImage() implemented as : void
OfaTreeOptionsDialog::loadImage( const ResId& i_rId, ImageButton&
i_rButton )




On that ImageButton you can use SetModeImage to set the image to be
displayed (which you should change when transitioning between
locked/unlocked state).


Indeed, I used the same code, and it works, but not completely. The
problem I got, is only one image is shown, means only the one
initialized in the Ctor.

The way you describe it you created two buttons where you wanted to have one button and two images. I'd use one ImageButton and set the apropriate image on it when changing state.

So as resource have

Image IMAGE_PADLOCK_OPEN
{
 ImageBitmap = Bitmap
 {
  File = "Padlock1_open.png";
 };
};

Image IMAGE_PADLOCK_CLOSED
{
 ImageBitmap = Bitmap
 {
  File = "Padlock1_closed.png";
 };
};

ImageButton BTN_PADLOCK
{
 Pos = MAP_APPFONT ( (COL_3 + COL_4 )/2 + 5, ROW_3 - 20 ) ;
 Size = MAP_APPFONT ( 16 , 16 ) ;
 TabStop = TRUE ;
 QuickHelpText [ en-US ] = "Click to lock" ;
 QuickHelpText [ fr ] = "Cliquer pour verrouiller" ;
};

and then use SetModeImage to set the image on the one button, when t changes state.


- shall I create and instantiate 2 ImageButton and Hide() / Show() them
instead of just loadImage() them ?

Possible, but not necessary.

- is there a method I missed to change the image with the new one
locking, unlocking the padlock ?

Possibly call Invalidate() after changing the image on the button; I'd expect that not to be necessary, but am not sure.

Kind regards, pl

--
"If the designers of X-window built cars, there would be no fewer than five
 steering wheels hidden about the cockpit, none of which followed the same
 principles -- but you'd be able to shift gears with your car stereo.
 Useful feature, that."
                -- From the programming notebooks of a heretic, 1990.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@gsl.openoffice.org
For additional commands, e-mail: dev-h...@gsl.openoffice.org

Reply via email to