TabBar whose style can be changed dynamically based on JvTabBar - delphi

I have tried many different libraries, but none came.
None of them can not be specified without introducing his own style in Painter.
I need to be able to quickly and dynamically change the style tab.
In response, I showed my developments.
If someone has similar developments - write them in response.

I decided to upgrade the simplest of them: TJvTabBar of JVCL (latest revision: 13415)
Here is the result.
Before (default)
After
Style sources (All graphics imported from png files with transparency)
Easy apply any personal style to any JvTabBar
var tmp:TStrings;
begin
tmp:=TStringList.Create;
tmp.Values['TOP_background']:= ExtractFileDir(Application.ExeName)+'\skins\default\tabs-TOP_background.png';
tmp.Values['TOP_active_left_side']:= ExtractFileDir(Application.ExeName)+'\skins\default\tabs-TOP_active_left_side.png';
tmp.Values['TOP_active_right_side']:= ExtractFileDir(Application.ExeName)+'\skins\default\tabs-TOP_active_right_side.png';
tmp.Values['TOP_active_center']:= ExtractFileDir(Application.ExeName)+'\skins\default\tabs-TOP_active_center.png';
tmp.Values['BOTTOM_background']:= ExtractFileDir(Application.ExeName)+'\skins\default\tabs-BOTTOM_background.png';
tmp.Values['BOTTOM_active_left_side']:= ExtractFileDir(Application.ExeName)+'\skins\default\tabs-BOTTOM_active_left_side.png';
tmp.Values['BOTTOM_active_right_side']:= ExtractFileDir(Application.ExeName)+'\skins\default\tabs-BOTTOM_active_right_side.png';
tmp.Values['BOTTOM_active_center']:= ExtractFileDir(Application.ExeName)+'\skins\default\tabs-BOTTOM_active_center.png';
tmp.Values['CLOSEBUTTON_normal']:= ExtractFileDir(Application.ExeName)+'\skins\default\tabs-CLOSEBUTTON_normal.png';
tmp.Values['CLOSEBUTTON_selected']:= ExtractFileDir(Application.ExeName)+'\skins\default\tabs-CLOSEBUTTON_selected.png';
tmp.Values['CLOSEBUTTON_disabled']:= ExtractFileDir(Application.ExeName)+'\skins\default\tabs-CLOSEBUTTON_disabled.png';
tmp.Values['CLOSEBUTTON_closing']:= ExtractFileDir(Application.ExeName)+'\skins\default\tabs-CLOSEBUTTON_closing.png';
tmp.Values['CLOSEBUTTON_modified']:= ExtractFileDir(Application.ExeName)+'\skins\default\tabs-CLOSEBUTTON_modified.png';
tmp.Values['CLOSEBUTTON_closing_modified']:= ExtractFileDir(Application.ExeName)+'\skins\default\tabs-CLOSEBUTTON_closing_modified.png';
JvTabBar1.StyleImages:=tmp;
tmp.Values['BOTTOM_background']:= ExtractFileDir(Application.ExeName)+'\skins\default\MYMOD_tabs-BOTTOM_background.png';
JvTabBar2.StyleImages:=tmp;
Main changes
Added ability to specify their own style ( JvTabBar1.StyleImages )
Added the ability to move the close button to the right ( JvTabBar1.CloseButtonRight: = true or false )
Many fixes to the size and position of text / icons / buttons / scroll
My JvTabBar.pas mod You can download it here http://pastebin.com/JmbufHy0
And example source style + JvTabBar.pas http://www.sendspace.com/file/shhuzr

Related

How can I use ALL system registered themes/styles in my Delphi App?

With Vcl.Themes.TStyleManager.StyleNames, I have access to just the style names enabled in the project options (Application/Appearance).
How can I list all of the style names registered in the system, and make it active in Delphi 11?
This is how I fill a TComboBox with the available styles:
procedure FillComboboxWithStyles;
var
stylename: string;
begin
for stylename in TStyleManager.StyleNames do
CBVclStyles.Items.Add(stylename);
end;
To activate a certain style you fill TStyleManager.SetStyle(const Name: string) with the stylename. For example the selected one from the TComboBox.
if (CBVclStyles.ItemIndex >= 0) then
TStyleManager.SetStyle(CBVclStyles.Items[CBVclStyles.ItemIndex])
else
;// handle a non-selected style
Don't forget Vcl.Themes in your uses.
You can include the style files (*.vsf from C:\Program Files (x86)\Embarcadero\Studio\22.0\Redist\styles\vcl with 22.0 marking your RAD Studio version) along with (externally from) your .EXE and then iterate over them when you fill your ComboBox. Then manually load the style from the file with TStyleManager.LoadFromFile when selected.
This will also allow your user to add his own style files to the setup.
This, I believe, is what the IDE does (except that it reads the list directly from the folder, since there's no "installation" of a style other than making the file available in a recognized location).

How to refresh child objects in desktop testing with TestComplete

There is a desktop window, which has more tabs, and some tabs include a text editor.
The editor buttons have the following mapping on the first tab (simplified here):
Window.PageControl.Tab1.Editor.Panel.Button1
Window.PageControl.Tab1.Editor.Panel.Button2 and so on.
The editor buttons have the following mapping on the second tab (simplified here):
Window.PageControl.Tab2.Editor.Panel.Button1
Window.PageControl.Tab2.Editor.Panel.Button2 and so on.
(Sometimes the Editor and other objects between Editor and Panel are cached and their mapping is not stable.)
I wrote a test which checks the functions of the text editor in the following way:
Window.PageControl.TabIndex := 1;
editor_test;
Window.PageControl.TabIndex := 2;
editor_test;
The editor_test looks like:
Window.PageControl.Refresh;
lprops := ['FullName','WndClass'];
lvals := ['*Panel', 'TWPToolPanel'];
ltarget := Aliases.(application name).Find(lprops,lvals,20,true);
ltarget.Button1.Click;
ltarget.Button2.Click...
editor_test properly works on any single tab of the window. Although, when I try to run the editor_test more times in one test, the test fails after changing tab, because it searches the buttons on the previous tab.
I tried Refresh and RefreshMappingInfo methods on the common parent object of the tabs (see above), but they doesn't help.
(The names and number of tabs can change in the window depending on the conditions.)
Is there any other way to clear cached mapping tree during test run? Is there any mistake in the concept?
Thank you in advance for any suggestion!
The solution was to complement the editor test in the following way:
lprops := ['FullName','WndClass', 'VisibleOnScreen'];
lvals := ['*Panel', 'TWPToolPanel', true];
Using this, TestComplete does not recognize editor buttons on inactive tabs of the window, which happened in the original scenario.

How to setup a TIcon instance to support alpha channel icons (SupportsPartialTransparency)

Using Borland C++ Builder 2009 I notice that when replacing images in a TImagelist, the alpha channel data gets corrupted somehow.
TIcon *Icon = new TIcon() ;
for (int x = 0 ; x < OS_Specific_count ; x++)
{
OS_xx_ImageList->GetIcon(x, Icon) ;
Use_ImageList->ReplaceIcon(x, Icon) ;
}
delete Icon ;
The problem is also described (+screenhots) in another Q ( TImageList - True color + alpha channel vs. 8-bit (256 colors) ) but I'm now trying to narrow things down with more specific questions.
While browsing TIcon in the help file I noticed a read-only property: SupportsPartialTransparency.
It appears to be false in my case, and I wonder if this is not the key to solving this problem ? Icon->Transparent = true does not set SupportsPartialTransparency to true !
I wonder what I can do to make sure the TIcon instance correctly 'gets' and 'replaces' the alpha channel information ?
The ImageLists are created at design time and have default properties (nothing changed) and contain 16x16 icons imported via the IDE. The imported icons contain alpha channel information.
I just use TPngImageList, it is compatible with TImageList. Plus the design-time editor is more flexible: You will need to convert .ico to .png. .
It is free and widely available, for example here: https://github.com/TurboPack. No headache with transparency since :) BTW, keeping icons as PNGs is more suitable, you can use them on other development tools and platforms.

How to custom alignment in Sublime Text 2?

Well I'm using Sublime Text 2 for a lot of tasks, included the creation of documents with LaTeX. I downloaded and installed the alignmentpackage and works great when I want to align respect the = symbol. But in LaTeX I need to align also with respect to & and sometimes % but I don't understand where or how can I custom that. I read the documentation about that package here, and now I see I must go to Preferences > Package Settings > Alignment > Settings – User but there the only I see is:
{
"color_scheme": "Packages/Color Scheme - Default/Monokai Bright.tmTheme",
"font_size": 12.0,
"ignored_packages":
[
"Vintage",
"PyV8"
]
}
And I don't know what exactly should I add, and if it's before close the {} o later opening a new pair. Could someone help me with that?
On my mac you would need to look at Alignment/Base File.sublime-settings
// The mid-line characters to align in a multi-line selection, changing
// this to an empty array will disable mid-line alignment
"alignment_chars": ["="],
Add the characters you want to align on either to this file, or create a user settings file as you indicated.
"alignment_chars": ["=", "%", "&"],
The contents of the file you listed is actually your user system preferences, not the user settings file for Alignment.

Looking for a more flexible tool than GNU indent

When I run indent with various options I want against my source, it does what I want but also messes with the placement of *s in pointer types:
-int send_pkt(tpkt_t* pkt, void* opt_data);
-void dump(tpkt_t* bp);
+int send_pkt(tpkt_t * pkt, void *opt_data);
+void dump(tpkt * bp);
I know my placement of *s next to the type not the variable is unconventional but how can I get indent to just leave them alone? Or is there another tool that will do what I want? I've looked in the man page, the info page, and visited a half a dozen pages that Google suggested and I can't find an option to do this.
I tried Artistic Style (a.k.a. AStyle) but can't seem to figure out how to make it indent in multiples of 4 but make every 8 a tab. That is:
if ( ... ) {
<4spaces>if ( ... ) {
<tab>...some code here...
<4spaces>}
}
Uncrustify
Uncrustify has several options on how to indent your files.
From the config file:
indent_with_tabs
How to use tabs when indenting code
0=spaces only
1=indent with tabs, align with spaces
2=indent and align with tabs
You can find it here.
BCPP
From the website: "bcpp indents C/C++ source programs, replacing tabs with spaces or the reverse. Unlike indent, it does (by design) not attempt to wrap long statements."
Find it here.
UniversalIndentGUI
It's a tool which supports several beautifiers / formatters. It could lead you to even more alternatives.
Find it here.
Artistic Style
You could try Artistic Style aka AStyle instead (even though it doesn't do what you need it to do, I'll leave it here in case someone else finds it useful).
Hack around and change its behavior editing the code. It's GNU after all. ;-)
As it's probably not the answer you wanted, here's another link: http://www.fnal.gov/docs/working-groups/c++wg/indenting.html.

Resources