Customized Scrollbar | developer.brewmp.com Customized Scrollbar | developer.brewmp.com

Developer

Customized Scrollbar

Is there any way for us to import our own scrollbar i.e. up and down arrows, slider to be bitmap or different colors?

thanks.

You can customize the arrows by setting the PROP_IMAGESTRIP_H and PROP_IMAGESTRIP_V properties of the scrollbar widget. It takes an IBitmap as the parameter. For the slider, you can only change the color.
For example:
IBitmap *piUpBitmap;
IBitmap *piDownBitmap;
// Load up the bitmaps
. . .
// Set the bitmaps
IWIDGET_SetProperty(piw, PROP_IMAGESTRIP_H, piUpBitmap);
IWIDGET_SetProperty(piw, PROP_IMAGESTRIP_V, piDownBitmap);

You can customize the arrows by setting the PROP_IMAGESTRIP_H and PROP_IMAGESTRIP_V properties of the scrollbar widget. It takes an IBitmap as the parameter. For the slider, you can only change the color.
For example:
IBitmap *piUpBitmap;
IBitmap *piDownBitmap;
// Load up the bitmaps
. . .
// Set the bitmaps
IWIDGET_SetProperty(piw, PROP_IMAGESTRIP_H, piUpBitmap);
IWIDGET_SetProperty(piw, PROP_IMAGESTRIP_V, piDownBitmap);

Wrap the scrollbar in a draw decorator. Set the end pad to give enough room for the arrow images. Then in the draw handler use IWIDGET_GetScrollbarRect(), IWIDGET_GetScrollHandleRect(), and IWIDGET_GetScrollEndPad() to figure out where to draw the arrows and the thumb.
-Erik

Wrap the scrollbar in a draw decorator. Set the end pad to give enough room for the arrow images. Then in the draw handler use IWIDGET_GetScrollbarRect(), IWIDGET_GetScrollHandleRect(), and IWIDGET_GetScrollEndPad() to figure out where to draw the arrows and the thumb.
-Erik

Erik,
I tried something simliar to what you are proposing.
The only downside was that I was unable to "overlay" my newly drawn scrollbar on top of the old one.
In the DrawDecorators DrawHandler, I had to remove the call to the Scrollbar's drawHandler and instead directly draw the whole bar myself and invoke IWIDGET_DRAW on its child Widget. Otherwise any rectangles I attempted to draw would not appear.
I also tried drawing my rectangles (From the DrawDecorator) first, then draw the scrollbar, this only resulted in my scrollbar moving the real scrollbar out of the way and throwing everything out of whack. I'm working in a constraint container btw, this might be the problem.
Any ideas or tips for overlaying my own drawings over existing widgets?
Eric

Erik,
I tried something simliar to what you are proposing.
The only downside was that I was unable to "overlay" my newly drawn scrollbar on top of the old one.
In the DrawDecorators DrawHandler, I had to remove the call to the Scrollbar's drawHandler and instead directly draw the whole bar myself and invoke IWIDGET_DRAW on its child Widget. Otherwise any rectangles I attempted to draw would not appear.
I also tried drawing my rectangles (From the DrawDecorator) first, then draw the scrollbar, this only resulted in my scrollbar moving the real scrollbar out of the way and throwing everything out of whack. I'm working in a constraint container btw, this might be the problem.
Any ideas or tips for overlaying my own drawings over existing widgets?
Eric

When you call a child's draw function, the child can (and most probably will) change the canvas' clip rect. So you need to get the canvas' clip rect, store it aside, call the child's draw function, and then reset the clip rect to its original value.
-Erik

When you call a child's draw function, the child can (and most probably will) change the canvas' clip rect. So you need to get the canvas' clip rect, store it aside, call the child's draw function, and then reset the clip rect to its original value.
-Erik