Hi Philipp,
Thanks for your light speed answer :)
I didn't answer immediately, because I wanted to experiment first.
Le 4 mars 10 à 14:42, Philipp Lohmann a écrit :
On 3/4/10 2:34 PM, eric b wrote:
Hello,
I'd like to implement a feature into the Tools -> Options dialog (
svx/source/cui/treeopt.* connected to optgdlg.* )
[...cut...]
What is the right way to achieve that ? More precisely, what type if
image use ? ( ImageButton ? Image ? other ? ) .. and shall I
implement
the drawing, and the rendering myself ? (that's what I saw in
backingwindow.cxx)
Actually that's not what you saw, the ImageButtons in
backingwindow.cxx are regular image buttons.
Ok.
The BitmapEx drawn there is the background for the window, not the
buttons.
Yes, I know (I did a complete relayout in the start center, to learn
its foundations)
I'd say, yes, use an ImageButton.
I did :)
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.
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.
The load the images from a resource file; actually for this you can
take backingwindow.cxx as an Example.
What I did :
1) in .src
declare a color mask :
#define MASKCOLOR MaskColor = \
Color { Red = 0xFFFF ; Green = 0x0000 ; Blue = 0xFFFF ; };
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.
As you noticed, I initialized the imagebutton with the open paclock.
It works well, but the closed padlock can never be displayed. Instead
I got a transparent button, but no image.
What did I forget ?
For example, when I unlock/lock the padlock, I use the following
action -see the code below- (after a click on the ImageButton), where
IsPadlockLocked() is a method from the aOfMiscTabPage using itself an
SfxPasswordDialog. :
IMPL_LINK( OfaTreeOptionsDialog, PadlockHdl_Impl, ImageButton *,
EMPTYARG )
{
if ( pCurrentPageEntry && aTreeLB.GetParent( pCurrentPageEntry ) )
{
OptionsPageInfo* pPageInfo = (OptionsPageInfo *)
pCurrentPageEntry->GetUserData();
if ( pPageInfo->m_pPage )
{
if ( ( OFA_TP_MISC == pPageInfo->m_nPageId ) )
{
OfaMiscTabPage * pOfaMiscTabPage = (OfaMiscTabPage
*)pPageInfo->m_pPage;
if ( pOfaMiscTabPage )
{
bool bIsLocked = pOfaMiscTabPage->IsPadlockLocked
();
#ifdef DEBUG
fprintf( stdout, "pOfaMiscTabPage =
(OfaMiscTabPage *)pPageInfo->m_pPage , bIsLocked == %d \n", bIsLocked);
#endif
if ( bIsLocked )
loadImage( SVX_RES( IMAGE_PADLOCK_CLOSED ),
aPadlockImageButton );
else
loadImage( SVX_RES( IMAGE_PADLOCK_OPEN ),
aPadlockImageButton );
}
}
}
}
return 0;
}
My questions :
- shall I create and instantiate 2 ImageButton and Hide() / Show()
them instead of just loadImage() them ?
- is there a method I missed to change the image with the new one
locking, unlocking the padlock ?
Thanks in advance :)
Just my 2 cents, pl
As usual, this helped me a lot :)
Kind regards,
Eric
--
qɔᴉɹə