Recent

Author Topic: New version of SpkToolbar  (Read 27634 times)

wp

  • Hero Member
  • *****
  • Posts: 6346
New version of SpkToolbar
« on: June 02, 2012, 11:43:06 pm »
In the attachment I am posting an extended and corrected version of SpkToolbar (v0.2). These are the changes:

* Added TSpkCheckbox and TSpkRadiobutton (unit spkt_Checkboxes.pas). I was missing some checkable buttons in the old version.
* Applied ImageIndex when assigning an action
* Added a property editor for image index
  - use specialized ImageIndexPropertyEditor to link to the imagelist
  - assign default values to ImageIndex properties
  - use types TImageIndex instead of integer
* Make sure that item properties (caption, imageindex etc) are updated when the action changes
* Fixed button state to change immediately after mouse-up from pressed to hover, the old version needed a mouse move to change button color
* Found bug in ComponentEditor form causing "Class not found" error: tabs, panes, and items were added without names. Assigning a name by FDesigner.UniqueName fixed the issue.
* Duplicate components after Cut & Paste because missing destruction of components after deletion from internal list
* Naming issue of components added by designer (counter starting at 2, not 1) fixed
* Changed default color of the SpkToolbar to clSkyBlue
* Added component icon to the package
* Changed {$mode delphi} to {$mode objfpc}

There are also two more demos: the first one shows how the toolbar can be used at runtime only (without installation), the second one demonstrates the usage of actions.

Note that there are still two bugs in design mode:
* Add a SpkToolbar, double-click and add tabs, panes and buttons. Compile and run. Lazaraus will complain about missing units that implement the added controls. Either add these units (spkt_Tab, spkt_Pane, spkt_Buttons, spkt_Checkboxes) manually to the uses clause. Simpler: just add any other component to the form, and delete it again, then the missing units are added automatically to the uses clause
* Delete the SpkToolbar (having tabs, panes, buttons) from the form. The toolbar disappears, but the added controls, however, are left in the form declaration. So far, I could not find how to delete these controls in design mode without crashing Lararus.

It would be nice if somebody with write permission could add these updated units to the CCR. Also, it would be find if someone who speaks polish would translate the polish comments.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

LuizAmérico

  • Sr. Member
  • ****
  • Posts: 458
Re: New version of SpkToolbar
« Reply #1 on: June 03, 2012, 01:22:53 am »

wp

  • Hero Member
  • *****
  • Posts: 6346
Re: New version of SpkToolbar
« Reply #2 on: June 03, 2012, 01:37:53 am »
Here it is
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

LuizAmérico

  • Sr. Member
  • ****
  • Posts: 458
Re: New version of SpkToolbar
« Reply #3 on: June 03, 2012, 03:34:16 am »
Thanks. The patch needs some cleanups before being applied since it does a lot of thing in one go. Also is giving an error while applying it.

1) The change to mode objfpc does not bring any code benefit, it just creates pollution, it also will make harder to merge changes from original delphi (if any). Please revert with related changes

2) there are some code formatting, this makes harder to review the actual changes. You can send a patch later with only formatting

3) The component icon should go in register unit, this will make the end user executable smaller. See other components source code in Lazarus svn

4) Please send a patch with the demo project separated

5) Avoid double type check like

+if AItem is TSpkComponent then
+   (AItem as TSpkComponent).FCollection := self;

you can do

+if AItem is TSpkComponent then
+   TSpkComponent(AItem).FCollection := self;





wp

  • Hero Member
  • *****
  • Posts: 6346
Re: New version of SpkToolbar
« Reply #4 on: June 03, 2012, 06:25:22 pm »
Ok, here are two patches modified according to your suggestions, one for the component source, the other one for the demos.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

LuizAmérico

  • Sr. Member
  • ****
  • Posts: 458
Re: New version of SpkToolbar
« Reply #5 on: June 04, 2012, 03:08:48 am »
Thanks. Applied with minor changes.

But there are some problems:

- The new components and new icon are not registered in the ide they should go in RegisterSpkToolbar.pas. The files should be added also to the package.

- The basic demo was not updated. Please update the svn and create a new patch

Sternas Stefanos

  • Full Member
  • ***
  • Posts: 167
  • Ex Pilot, M.Sc, Ph.D
    • http://www.pilotlogic.com
Re: New version of SpkToolbar
« Reply #6 on: June 04, 2012, 09:38:09 am »

Try this

procedure Register;
begin
  RegisterComponents('SpkToolbar', [TSpkToolbar]);

  //.....
  RegisterClasses([TSpkLargeButton, TSpkSmallButton]);
  RegisterNoIcon([TSpkLargeButton, TSpkSmallButton]);

  RegisterClasses([TSpkPane]);
  RegisterNoIcon([TSpkPane]);

  RegisterClasses([TSpkTab]);
  RegisterNoIcon([TSpkTab]);

  //.....
  RegisterComponentEditor(TSpkToolbar, TSpkToolbarEditor);
  RegisterPropertyEditor(TypeInfo(TSpkToolbarAppearance), TSpkToolbar,
                         'Appearance', TSpkToolbarAppearanceEditor);

  //todo: register Caption Editor
end;             
CodeTyphon Architect and Programmer

wp

  • Hero Member
  • *****
  • Posts: 6346
Re: New version of SpkToolbar
« Reply #7 on: June 04, 2012, 10:59:54 pm »
Here everything is fine, but when I update from the svn the component goes crazy. It looks as if my patch does not update all the necessary files in the repository.

It is strange, but the files missing have a mime-type "plain/text", instead of the usual "text/plain". All other files that I checked in my local repository have "text/plain", as well. Could it be that my TortoiseSVN refuses to consider different mime types for patching or updating? I changed their mime-type to text/plain, but I don't know if that helps.

Anyway, I'll give it another try. Find in the attachment two zip files: the first one contains the component and demo patches, the other one the full source of TSpkComponent - in case something would go wrong with the patches again.

BTW: Since nobody could have used the faulty component so far I took the freedom to change the declaration of the OnTabChanging event (adding an "Allow" parameter) because I need a way to inhibit changing tabs in certain cases.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

LuizAmérico

  • Sr. Member
  • ****
  • Posts: 458
Re: New version of SpkToolbar
« Reply #8 on: June 05, 2012, 05:00:53 am »
Thanks. I'll look tomorrow night.

LuizAmérico

  • Sr. Member
  • ****
  • Posts: 458
Re: New version of SpkToolbar
« Reply #9 on: June 06, 2012, 03:29:18 am »
Applied with some modifications

wp

  • Hero Member
  • *****
  • Posts: 6346
Re: New version of SpkToolbar
« Reply #10 on: June 06, 2012, 08:51:04 am »
Tested the version from svn, it is running fine now. Thank you.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

JD

  • Hero Member
  • *****
  • Posts: 1758
Re: New version of SpkToolbar
« Reply #11 on: June 09, 2012, 11:46:04 am »
Tested the version from svn, it is running fine now. Thank you.

Just tried the svn version & I'm sorry but it's not running fine at all! One still has to manually add the necessary pascal files to a project's unit clause before the project can be compiled.

I attach a demo project for your review.

Keep up the good work.

JD
Windows (10, 7) - Lazarus 2.0RC3/FPC 3.2, NewPascal, Delphi

Indy 10.6 series; mORMot; Zeos 7.2.1; SQLite, Firebird, PostgreSQL & MariaDB; VirtualTreeView 5.5.3 R1

wp

  • Hero Member
  • *****
  • Posts: 6346
Re: New version of SpkToolbar
« Reply #12 on: June 09, 2012, 01:06:09 pm »
Maybe the expression "running fine" was too positive, I was referring to the issues with adding to svn. The issues mentioned in the first posting still exist.

As a workaround, just add a second SpkToolbar to the form (or any other component) and delete it again. You will have the missing units in the uses clause afterwards.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

JD

  • Hero Member
  • *****
  • Posts: 1758
Re: New version of SpkToolbar
« Reply #13 on: June 09, 2012, 02:36:20 pm »
As a workaround, just add a second SpkToolbar to the form (or any other component) and delete it again. You will have the missing units in the uses clause afterwards.

You're right. Adding a second SpkToolbar to the form and then deleting it effectively adds the missing unit clauses. Funny!  :D
Windows (10, 7) - Lazarus 2.0RC3/FPC 3.2, NewPascal, Delphi

Indy 10.6 series; mORMot; Zeos 7.2.1; SQLite, Firebird, PostgreSQL & MariaDB; VirtualTreeView 5.5.3 R1

LuizAmérico

  • Sr. Member
  • ****
  • Posts: 458
Re: New version of SpkToolbar
« Reply #14 on: June 09, 2012, 06:39:56 pm »
I fixed the problem of the unit clause in svn, the missing references i could not fix