Difference between revisions of "BGRAControls"
Line 121: | Line 121: | ||
Set automatically (with Boolean option) the Width & Height of control when bitmap changes. AutoUpdateSize:=Boolean; | Set automatically (with Boolean option) the Width & Height of control when bitmap changes. AutoUpdateSize:=Boolean; | ||
+ | |||
+ | == TBGRAVirtualScreen == | ||
+ | |||
+ | The principle is to draw on a memory bitmap. | ||
+ | |||
+ | The component has a specific event, OnRedraw, which is called when the whole bitmap needs to be redrawn. It happends at the beggining, when resizing and when the Redraw method is called. | ||
+ | |||
+ | Otherwise, it is possible to modify the Bitmap property and call Invalidate or Repaint, to avoid erasing the whole bitmap content. |
Revision as of 22:33, 19 May 2011
Overview
Authors:
Dibo (package maintainer, TBGRAImageList, TBGRASpeedButton, TBGRAButton, TBGRAPanel)
Circular (TBGRAKnob, TBGRAFlashProgressBar, TBGRAVirtualScreen)
Emerson Cavalcanti (TBGRAImageManipulation)
Lainz (TBGRAImageButton)
License: Modified LGPL.
As many people know, Lazarus GTK doesn't have full alpha support. I created a set of components which use TBGRABitmap for drawing icons, so it partially solves the problem with alpha in GTK. But this components set is not only a GTK patch but has more fancy components which are using the power of the BGRABitmap package.
Related Articles
BGRAButton Gallery - Gallery of buttons with source code to use in your projects with BGRAButton.
Installation
BGRABitmap: http://wiki.lazarus.freepascal.org/BGRABitmap
BGRAControls: http://sourceforge.net/projects/bgracontrols/files/
Git repository: git://bgracontrols.git.sourceforge.net/gitroot/bgracontrols/bgracontrols
You need lazarus 0.9.31 from SVN (revision >= 29834).
You need to install the BGRABitmap package first (it is a requiered package in my package).
Install like other components by selecting bgracontrols.lpk from "Package->Open package file". This set of components is crossplatform (tested on linux GTK and windows)
Using
Drop TBGRAImageList or TBGRASpeedButton from "BGRA controls" palette and use like normal component. Example: Add icons, drop TToolBar and assign BGRAImageList to toolbar. Images property in object inspector.
TBGRAImageList
Before:
After:
Component which inherits from TImageList. So each control (tested on TToolBar and TTreeView) which is using TImageList.Draw method for drawing icons, automatically can have alpha support. Just use this component instead of TImageList. This component has been written for enabling GTK alpha, so on Windows (and other interfaces) it works just like normal TImageList (it doesn't use BGRABitmap for drawing)
TBGRASpeedButton
Component which inherits from TSpeedButton and draws the glyph using TBGRABitmap. This component has been written for enabling GTK alpha, so on Windows (and other interfaces) it works just like normal TImageList (it doesn't use BGRABitmap for drawing)
TBGRAButton
Customizable graphic component which is using only BGRABitmap functions for drawing. This component is insensitive for -dGTK_ONLY switch. Demo project included in package.
Functionality:
- Gradients
- Double gradients
- Rounding
- Border style, width and color
- Drop down list
- Glyph
- States (normal, hover, clicked)
- Caption with shadow
- Full alpha and antialias support
- Can work as image if no caption is set (has no stretch function yet)
ToDO:
I wanted to add "container" functionality (like TPanel) so this same component could be used as a toolbar with children but TCustomControl has no transparency.
I created a task for this issue in the forum: http://www.lazarus.freepascal.org/index.php/topic,12933.0.html
And a mailing list: http://lists.lazarus.freepascal.org/pipermail/lazarus/2011-April/062683.html
I tried to report this as a bug. Instead, I created TBGRAPanel with similar gradient functionality (but very limited).
TBGRAPanel
Simple TPanel descendant which can have gradient background. Created especially for TBGRAButton (for creating a nice looking toolbar for bgrabuttons). This component is insensitive for -dGTK_ONLY switch
TBGRAKnob
Graphic knob component created by circular.
TBGRAFlashProgressBar
Flash progressbar created by circular.
TBGRAImageManipulation
Graphic component created by Emerson Cavalcanti.
TBGRAImageButton
Component used to create a button with 4 states from Bitmap.
The bitmap must contain the 4 states (from top to bottom, with the same Height) in the following order: normal, enter, pressed, disabled.
<delphi>BitmapHeight:=36;</delphi>
ToDO:
Replace TBitmap with TBGRABitmap to implement alpha support.
Calculate and assign automatically the BitmapHeight.
Set automatically (with Boolean option) the Width & Height of control when bitmap changes. AutoUpdateSize:=Boolean;
TBGRAVirtualScreen
The principle is to draw on a memory bitmap.
The component has a specific event, OnRedraw, which is called when the whole bitmap needs to be redrawn. It happends at the beggining, when resizing and when the Redraw method is called.
Otherwise, it is possible to modify the Bitmap property and call Invalidate or Repaint, to avoid erasing the whole bitmap content.