Recent

Author Topic: [SOLVED] TECTabCtrl fonts, colors and other features.  (Read 1317 times)

Raul_ES

  • Full Member
  • ***
  • Posts: 183
  • My interests: Healthcare & Computers
    • My Linkedin Profile, you can add me to stay in contact.
[SOLVED] TECTabCtrl fonts, colors and other features.
« on: June 03, 2020, 08:07:42 pm »
Hello friends,


I have a ECtabctrl, a combobox and a Notebook, all linked in a way that whenever I add or remove or switch a tab the list of items in the combobox and the pages in the notebook are updated. Pages contain different kind of frames (Point of sale, store, invoices, customers...) and are generated at runtime. Employees have an user id.  Everything fine up to here.


Now, I am struggling to do the following with no success: The active tab has to be always yellow with geen bold fonts. The rest of the tabs must have regular default colored fonts, and their tab color will depend on the user id. If no user id is available (employee hast opened a pos with out identifying himself) the tab color will be the default clForm.


1 = active tab (it is also called visible tab? I have some confusion here, TabIndex != VisibleTabIndex)
2 = inactive tabs, hidden notebook pages
3 = combobox with captions of the pages
4 = minimize, close, lock, etc buttons

I'll post some code.
« Last Edit: June 03, 2020, 10:55:50 pm by Raul_ES »
Pharmacy + Chemistry + Biology + Healthcare + Computing

If you have any interest or project related with these areas feel free to contact me!

Raul_ES

  • Full Member
  • ***
  • Posts: 183
  • My interests: Healthcare & Computers
    • My Linkedin Profile, you can add me to stay in contact.
Re: TECTabCtrl fonts, colors and other features.
« Reply #1 on: June 03, 2020, 08:21:18 pm »
I guess that this will be achieved with the onChange event procedure:

Code: Pascal  [Select][+][-]
  1. procedure TmainScreen.ECTabCtrl_sheetTabChange(Sender: TObject);
  2. var
  3. i: integer;
  4.  
  5. begin
  6. (...)
  7. if ComboBox_sheets.Items.Count>0 then
  8. begin
  9.     ComboBox_sheets.ItemIndex:=ECTabCtrl_sheetTab.TabIndex;
  10.     Notebook.PageIndex:=ECTabCtrl_sheetTab.TabIndex;
  11. end
  12. (...)
  13.  

Switching, adding and removing pages works fine.

Here comes the problem. I have to iterate through all the tabs except the active one to change the font options
back to regular and the tab color has to be taken from the list of items. The items have the structure "[USER_ID - USER_NAME] CAPTION", so I need to extract USER_ID and get its associated personal color from a database or configuration file.

How do I chage the color/font options for the tabs?

Code: Pascal  [Select][+][-]
  1. // TabIndex, PageIndex = o-n
  2. // Tabs.Count, Pages.Count = 1-m
  3.  
  4. if Notebook.Pages.Count>1 then
  5. begin
  6. for i:= 0 to ECTabCtrl_sheetTab.Tabs.Count-1 do; // iterate through tabs
  7. begin
  8.   if not (i=ECTabCtrl_sheetTab.TabIndex) then
  9.      begin
  10.  
  11.        ECTabCtrl_sheetTab.Tabs.Items[i].FontOptions.FontStyles:=[];
  12.        ECTabCtrl_sheetTab.Tabs.Items[i].FontOptions.FontColor:= clDefault;
  13.        //if (ECTabCtrl_sheetTab.TabIndex mod 2) = 0 then
  14.        //    ECTabCtrl_sheetTab.Tabs.Items[ECTabCtrl_sheetTab.TabIndex].Color:=clMoneyGreen;
  15.      end else
  16.      begin
  17.        ECTabCtrl_sheetTab.Tabs.Items[i].FontOptions.FontStyles:=[fsBold];
  18.        ECTabCtrl_sheetTab.Tabs.Items[i].FontOptions.FontColor:= clGreen;
  19.      end;
  20. end;
  21. end;

Nothing works as expected.
« Last Edit: June 03, 2020, 08:25:35 pm by Raul_ES »
Pharmacy + Chemistry + Biology + Healthcare + Computing

If you have any interest or project related with these areas feel free to contact me!

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: TECTabCtrl fonts, colors and other features.
« Reply #2 on: June 03, 2020, 09:02:48 pm »
Yes, TabIndex doesn't have to match VisibleTabIndex.
Let's say you have 3 tabs. Tab 0 is visible, Tab 1 is invisible (or folded) and Tab 2 is visible and selected (a.k.a. active) then:
ECTC.VisibleTabIndex = 1
length(ECTC.VisibleTabs = 2
ECTC.TabIndex = 2
ECTC.Tabs.Count = 3

I am goiong to check your second post.
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: TECTabCtrl fonts, colors and other features.
« Reply #3 on: June 03, 2020, 09:49:51 pm »
Man, your code works, I just tested it.

But you have to remove that semicolon right after the loop!  :D

Code: Pascal  [Select][+][-]
  1. for i:= 0 to ECTabCtrl_sheetTab.Tabs.Count-1 do; // iterate through tabs
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

Raul_ES

  • Full Member
  • ***
  • Posts: 183
  • My interests: Healthcare & Computers
    • My Linkedin Profile, you can add me to stay in contact.
Re: TECTabCtrl fonts, colors and other features.
« Reply #4 on: June 03, 2020, 10:51:38 pm »
OMG

 :o :o :o :o :o :o :o :o :o :o :o :o I've been more than a week trying to figure out what the hell was going on

 :D :D :D

thanks Blaazen :D
Pharmacy + Chemistry + Biology + Healthcare + Computing

If you have any interest or project related with these areas feel free to contact me!

Raul_ES

  • Full Member
  • ***
  • Posts: 183
  • My interests: Healthcare & Computers
    • My Linkedin Profile, you can add me to stay in contact.
Re: TECTabCtrl fonts, colors and other features.
« Reply #5 on: June 03, 2020, 10:59:58 pm »
Yes, TabIndex doesn't have to match VisibleTabIndex.
Let's say you have 3 tabs. Tab 0 is visible, Tab 1 is invisible (or folded) and Tab 2 is visible and selected (a.k.a. active) then:
ECTC.VisibleTabIndex = 1
length(ECTC.VisibleTabs = 2
ECTC.TabIndex = 2
ECTC.Tabs.Count = 3

Blaazen sorry, but I don't really understand the concept of "visibility". All unfolded/not invisible tabs aren't suposed to be "visible"?
Pharmacy + Chemistry + Biology + Healthcare + Computing

If you have any interest or project related with these areas feel free to contact me!

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: [SOLVED] TECTabCtrl fonts, colors and other features.
« Reply #6 on: June 03, 2020, 11:56:21 pm »
Yes. Visible are those which you can click directly. Folded or invisible (i.e. etíoVisible is not in Tab.Options) are not in VisibleTabs array. But if you have many tabs in row and you have to scroll to reach them, they are still meant visible.

There's function IsTabVisible() with a misleading name because it checks also if tab is in a visble area of the component.
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

Raul_ES

  • Full Member
  • ***
  • Posts: 183
  • My interests: Healthcare & Computers
    • My Linkedin Profile, you can add me to stay in contact.
Re: [SOLVED] TECTabCtrl fonts, colors and other features.
« Reply #7 on: June 05, 2020, 02:16:07 pm »
Thank you Blaazen,

have a nice day
Pharmacy + Chemistry + Biology + Healthcare + Computing

If you have any interest or project related with these areas feel free to contact me!

 

TinyPortal © 2005-2018