Recent

Author Topic: Flying panel/toolbar/form (like Office toolbar)  (Read 31277 times)

x2nie

  • Hero Member
  • *****
  • Posts: 515
  • Impossible=I don't know the way
    • impossible is nothing - www.x2nie.com
Flying panel/toolbar/form (like Office toolbar)
« on: September 10, 2013, 08:48:11 am »
Halo guys ...!
I am really need your help. I have a question and any sample code.

Is there any way to show panel/form that has behavior like a popup menu ?
We know every TPopupMenu would be:
  • Showing without change the form.active
  • can track (detect) any mouse-movement

Additionally, I need to display TWincontrol that has above abilities plus :
  • Accept some TControl/TWinControl as it's children
  • Multiple menuitem per horizontal bar (like Google Chrome zoom menu item)
  • Cross-platform. It may has similar interaction when run on Windows, Linux or Mac OS.
  • Allow focus-control (like TEdit, TSpinEdit) is an advance, but not the highest priority for now

Simply, it is like what Office's toolbar could do. (OpenOffice toolbars, Microsoft Office toolbars).

-------------------------------------------------
Okay, for Delphi there is a famous VCL named Toolbar97 and it's sister: TB2K by Jordan Russel,
and futher of it is :TBX by Alex Denisov or SpTBXLib by SilverPoint.
But their softwares are hard to port to Lazarus, due they are depending to specific Windows functions (for message loop when popuping).
ExtToolbar was a port of Toolbar97 to Lazarus, but it did not yet able to show flying window such what Toolbar97 could do.
(I have ported both Toolbar97 and TB2K ver 2.2.2 by myself, but then these crash my Lazarus by showing long error message in the end when I clicked. I stoped developing them)

Maybe, toolbar library (such TB97/TB2K) was too complex to make compatible for Lazarus~CrossPlatfor?
I also port the small one: TColorPickerButton by Mike Lischke. (I put link in bottom)
But, again, it depends for specific Windows that I cant replace the for to run nicely in Lazarus. :(


So, I feel it would be better if we create a new library from scratch.
Then, here I am begging to you The Lazarus Community.

Perhaps, by show me (or someone like me) of  how to popup/show a form without activating the mainform? It would be great enough for the first step forward building our new library for Lazarus.



I am a bit new in Lazarus world. So I think any ideas / suggestion are very welcome.

--------------------------
Possible similar topic:
http://forum.lazarus.freepascal.org/index.php/topic,21970.msg129088.html
http://free-pascal-lazarus.989080.n3.nabble.com/Lazarus-Popup-window-td4028178.html
http://www.mail-archive.com/lazarus@lists.lazarus.freepascal.org/msg34890.html

ExtToolbar for lazarus:
http://forum.lazarus.freepascal.org/index.php/topic,10956.msg54705.html#msg54705

TColorPickerButton by Mike Lischke:
http://www.lischke-online.de/index.php/controls/color-picker-control
« Last Edit: September 10, 2013, 09:04:54 am by x2nie »
When you were logged in, you can see attachments.
Lazarus Github @ UbuntuCinnamon-v22.04.1 + LinuxMintDebianEdition5

zamtmn

  • Hero Member
  • *****
  • Posts: 594
Re: Flying panel/toolbar/form (like Office toolbar)
« Reply #1 on: September 10, 2013, 08:55:44 pm »
It would be nice to have such control. I need it to implement a similar combobox component. But I think it's very difficult to do cross platform, my small knowledge let me just dream about it

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Flying panel/toolbar/form (like Office toolbar)
« Reply #2 on: September 10, 2013, 09:40:23 pm »
there is no cross platform way that will allow you to create a popup form that will not still activation from the popup parent. As far as I know (and I would love to be proved wrong) win32 is the only api that distinguish between focus and activation and even that requires a lot of low level work to make it work. most of the solutions that I have seen they fake it by adding the popup form to the message loop of the popup parent (some like a child control but not quit) forwarding mouse and keyboard messages. I am aware that this have been enhanced in the latest .net framework and now it can be done easily there but on win32/64 it needs a lot of work.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

vrull

  • Full Member
  • ***
  • Posts: 118
Re: Flying panel/toolbar/form (like Office toolbar)
« Reply #3 on: September 11, 2013, 01:09:17 am »
Maybe I don't understand something in your requirements for the flying stuff, but I think I've made something similar without any specific tricks. In my project XML Tree Editor you can find a search form, which communicates with the main form or a notification, which does nothing, but still reacts on user clicks or clicks outside it. There are some user messages involved, but this seems to work in both Windows and Linux, and I believe on other platforms.
The source can be found http://sourceforge.net/projects/xmltreeeditor/files/?source=navbar

x2nie

  • Hero Member
  • *****
  • Posts: 515
  • Impossible=I don't know the way
    • impossible is nothing - www.x2nie.com
Re: Flying panel/toolbar/form (like Office toolbar)
« Reply #4 on: September 11, 2013, 05:48:41 am »
It would be nice to have such control. I need it to implement a similar combobox component. But I think it's very difficult to do cross platform, my small knowledge let me just dream about it
Hi zamtmn! I believe we could step that dream to the reality. I have seen that GTK and QT allow that.

there is no cross platform way that will allow you to create a popup form that will not still activation from the popup parent. As far as I know (and I would love to be proved wrong) win32 is the only api that distinguish between focus and activation and even that requires a lot of low level work to make it work.
most of the solutions that I have seen they fake it by adding the popup form to the message loop of the popup parent (some like a child control but not quit) forwarding mouse and keyboard messages. I am aware that this have been enhanced in the latest .net framework and now it can be done easily there but on win32/64 it needs a lot of work.

Thanks you tazz.
Yes, you right that: there is nothing yet to do that by calling a single function nor any class within Lazarus for cross platform currently.
But I found an opportunity (by using Lazarus), since Lazarus support several widgetset, wich are some widgetset suppports in cross-platform already. And there are some example of software implemented it.

I can make a prove about it:
  • Gimp show some panel like a popup-list / combobox-list; I think using GTK would also able
  • Calligra Word show panel as like as Gimp: without deactivating the main form. Proving QT could do too

(see attachments.)
Okay, I sew that proven within my Windows Machine, and I am not sure how they are looked at Linux / Mac or other.
But, by assuming wether GTK or QT each one has identical capabilty in major OS,
let we remember the jargon : "Lazarus, write once compile anywhere"

So, my idea is:
Perhaps, can we create a class or LCL library, that indeep implements specific trics/functions which are polymorphic based on widgetset used ? :)

I think it is not a difficult, and (sadly) not also easy for me to do that alone.

I've made something similar without any specific tricks. In my project XML Tree Editor you can find a search form, which communicates with the main form or a notification, which does nothing, but still reacts on user clicks or clicks outside it. There are some user messages involved, but this seems to work in both Windows and Linux, and I believe on other platforms.

Thanks vrull ! I am glad you give the code. I must try your software first, and learn your code. It may take some hours or days.
--------------------------------------

Anyhow, Do you same with me when thinking about : if widgetset supported by Lazarus supports the flying window, why Lazarus didnt support it yet?
I dont know the exact reason...
But, I felt that because the planning / scope of implementing it was too far.
In other hand, if we could implementing flying panel, it may attracts us to implement the next feature: docking-capability of that same panel.
(Actually it was my problem when trying to port the TB97 & TB2K to Lazarus: how it will be docked?)

So now, let we make this task easy to achieve:
  • Focus on how flying panel available by Lazarus for cross platform, first. Dont care about docking aspect
  • Make it simple but useful.  For example: let display a TPanel with some TButton as it chidren, flying!
    (some demos would be great for testing in many platform / widgetset)
  • Make it stable and portable (major widgetset supported by lazarus has no problem)
  • Think about dockable / dragable later

Oh, why?
Because, I think : not every need of flying panel is also the need of dockable aspect.

Yeah, that above is my brain content.
Do you have any better ideas ?

Okay,
Thanks you everybody. Your contribution to this task will be valuable for me and the community.
« Last Edit: September 11, 2013, 06:00:58 am by x2nie »
When you were logged in, you can see attachments.
Lazarus Github @ UbuntuCinnamon-v22.04.1 + LinuxMintDebianEdition5

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Flying panel/toolbar/form (like Office toolbar)
« Reply #5 on: September 11, 2013, 07:00:25 am »
floating toolbar type of form is easy and can be done now using the PopupParent and PopupMode properties of a form (although the last time checked it did not work on QT 4) but the moment the popup form is selected it gets the focus from the parent form and the caption is painted in deactivated mode. Although I have a couple of controls that mimic a combo box with a custom drop down form I haven't so far found any way to allow the main form to retain the activated colors when the drop down form has the focus in a cross platform way.

In windows you can take over the parent window loop (I think it is called subclassing) and fake the activation and all but I do not knowIf any thing similar is supported in other widgetsets.

see attached a working example of a custom combo in my task list.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

x2nie

  • Hero Member
  • *****
  • Posts: 515
  • Impossible=I don't know the way
    • impossible is nothing - www.x2nie.com
Re: Flying panel/toolbar/form (like Office toolbar)
« Reply #6 on: September 11, 2013, 08:07:10 pm »
floating toolbar type of form is easy and can be done now using the PopupParent and PopupMode properties of a form...

Okay taazz. it works... But I didnt see any advantage between of setting those properties or not.
Would you like give use any link useful talking about those properties topic?

Bytheway, last minutes ago I successful to display a TWinControl as popup without changing it's form.active state. It was based on TColorPickerButton by Mike Lisckhe.
It is small enough to learn the code (only 3 classes = 1 LCL registred class).
I keep it compatible with Delphi for respect to the original author and his community.

I wish, In future, I can extract it's portion codes into another class as a base for totally new flying TForm/TWinControl. If somebody want to play / try / learn with it, I attached the codes below.
Note: currently only work in Lazarus Windows widgetset and depends to Windows (doh! :( )

---------------------
In windows you can take over the parent window loop (I think it is called subclassing) and fake the activation and all but I do not knowIf any thing similar is supported in other widgetsets.
Yes! The TMessage(s)' loop is amazing. I noticed that by using it, we could make TToolbar more responsive as like as TMainMenu's popups class.

But how? Would you like to give us a sample code or a mini demo project ?
any articles/url will also be nice to visit.

For me, I saw that on TB2k source codes which is too complex to be extracted, unstable running in Lazarus.
If you or somebody need the ported code of TB97 for lazarus, I will upload that here.
Yeah, I didnt yet put here due I think it is irrelevant (begging help vs announcement of third-party LCL).

For the early progress, depends on single widgetset is fine, isn't it?
If it was stable, I wish somebody would translate it into another widgetset. (I dream it  :P ha ha ha...)

Again, any correction O:-), suggestion although comments  :-*  or any imagination ideas are very welcome !!   8-)
When you were logged in, you can see attachments.
Lazarus Github @ UbuntuCinnamon-v22.04.1 + LinuxMintDebianEdition5

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Flying panel/toolbar/form (like Office toolbar)
« Reply #7 on: September 13, 2013, 11:16:43 am »
Let me try to explain the popupParent and PopupMode properties. Popupmode has 3 values pmNone is the default and means none popup logic at all, pmExplicit means that the popup parent is defined by the popupParent property, pmAuto means that the form will always be in popup mode and the popupParent will be automatically chosen in which case most of the times is the application main form.

What PopupParent and popupMode do is nothing more than a way to define a z order on your forms that will be always respected. For example when a form a popupParent equal the main form of the application then when the main form gets the focus then the popup form will always float above the main form other forms might float above main form and the pop up form or be below the main form but the popup form can never be below the main or what ever the popupParent is pointing to.

thats all there is to those two properties and it is a big help when used for toolbars that suppose to always float above a specific form eg there is no use to toolbar that the moment you select the editing form it goes behind it and there is no way to click the tool button other than restoring the editor form from maximized state move it around and select the toolbar floating window to come on top so you can click the tool button you need.

As for the TWinControl descendant as a floating window is a good solution for compound components that mimic a combo box like the color picker you are talking about but it would be a pain to create such a component every time you need a combo layout that is not supported like the combo box screen shot I posted in my last post. There should be a way to build a popup form using existing controls with out the need to write and install components that will be used on a single application only. That is why I'm searching a solution based on forms and not on TWinControl although I love the TWinControl idea and I'll probably use it in my ported color library to create a color combo and other types of combo box.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

x2nie

  • Hero Member
  • *****
  • Posts: 515
  • Impossible=I don't know the way
    • impossible is nothing - www.x2nie.com
Re: Flying panel/toolbar/form (like Office toolbar)
« Reply #8 on: September 18, 2013, 07:05:21 am »
Maybe I don't understand something in your requirements for the flying stuff, but I think I've made something similar without any specific tricks. In my project XML Tree Editor you can find a search form, which communicates with the main form or a notification, which does nothing, but still reacts on user clicks or clicks outside it. ...
Hi vrull, I've learn your code. Thanks you for show us your codes.
I need something like that, but without deactivate the main form.
I may use the message mechanism for future when I am ready to the next step.
----------------------------------------------

Dear Tazz..
Oh, I am not notice before about the z order. Yes, those 2 property make my "popup" form always on top of it's PopupParent (the mainform).

Okay, now...
So far, we found 2 candidate solution:
*  Your CustomCombobox (TForm)  ;D
and
*  "My" Popup (TWincontrol). It's not exactly mine, I am not the original author, but I bring it here.
     so just to distinct it with your suggested solution I call it "my". :)

I repeat again:
I have to make a choice between 2 solution as a solution of flying container question:
1 -> Using TForm (or TCustomForm) as flying container +PopupMode + PopupParent
2 -> Using TWinControl with hack ( +CreateParams +CreateWnd +event.Show(). )

Pro & Con :
* First solution,
   (+) Already Lazarus cross platform.
   (+) it also give us a chance to arrange controls such buttons, labels, TEdit visually.
   ( - ) But it always change the mainform activation (shown by color of mainform's titlebar).

* Second solution,
   ( - ) currently Lazarus in Windows only.
   (+) It never activated (mean: mainform's title bar color seem as the active control).
   ( - ) Sadly, it doesn't give us ability to arrange controls visually (via form designer in design-time).

---------------------
So, I think it maybe better if we could marriage both solution, := make a new hybrid solution (rather than choosing only one of them)
:
A. --> Transfer the content in runtime.
          Suppose we put & arrange some controls (buttons, labels, TEdits) in a form (like your combobox form)
         And, when it needed to be shown (in runtime), we create a new TWincontrol and transfer the
         form's children into that new TWincontrol created.
B. --> Make it designable visually in :
         The "flying TWincontrol" it self is inherited from a TWincontrol which is already available in lazarus   
         (visible in design time).
         We can create a new TWincontrol (+hack for flying capability) based on TPanel, for example.
         By this, your expectation to able to put and move any buttons, labels, combobox will be achieved.

Solution A: not only from TForm, it might also transfered it's children from TPanel.
Solution B: no need to transfer, it self able to fly when needed.

The goal of both solutions is to bring a flying window (TWinControl) in runtime, plus ability to arrange/move controls in design time, PLUS: without changing the current active form (mainform must be remain active control).

The difference between them is : implementing Solution B need registering of that new LCL by installing a new component package (*.lpk), therefor we must put that hacked panel into our form from component palette (as similar as putting a TPanel from Lazarus's Component Palette).

---------------------------
I mean, PopupMode and PopupParent of TForm are OK, except I just dislike that using TForm will always grab it's parent-form's Active property. While I expect the PopupParent will always the active.

In other hand, if we success to work with TWinControl as popup form, I am not sure if we can make it cross platform (run well in WIndows, Linux, MacOS) :(


What is your oppinion ?
-------------------

Thanks you!
When you were logged in, you can see attachments.
Lazarus Github @ UbuntuCinnamon-v22.04.1 + LinuxMintDebianEdition5

x2nie

  • Hero Member
  • *****
  • Posts: 515
  • Impossible=I don't know the way
    • impossible is nothing - www.x2nie.com
Re: Flying panel/toolbar/form (like Office toolbar)
« Reply #9 on: September 18, 2013, 07:24:01 am »
..., I am not sure if we can make it cross platform (run well in WIndows, Linux, MacOS) :(

I correct my own statement. It must be:
"I am not sure if I can make it crossplatform by myself." :D

Meaning: I am begging to the Lazarus community to make it cross platform, next time.
As you can see in my previous posts in this topic, I attached several screenshoot about GTK & QT able to do it (flying window without deactivate it's parent from)

So, I believe we could make it crossplatform (using QT, GTK+, Windows), next time / some day.
I just dont know "how" to make it happens by using Lazarus, in nowdays.
When you were logged in, you can see attachments.
Lazarus Github @ UbuntuCinnamon-v22.04.1 + LinuxMintDebianEdition5

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Flying panel/toolbar/form (like Office toolbar)
« Reply #10 on: September 18, 2013, 07:47:11 am »
Try to search for mustangpeek dropdownform for delphi (I think I have a copy somewhere on my disk that I can share if you like). TDropDownForm is nothing more than a hack based on TForm that keeps the parent form activated all the time, it meets all the requirements listed here so far except it is windows specific, if you are going down the road of windows specific then that is the ideal solution for that problem.

Although I have worked with both QT and GTK2 on a windows machine my experience with those widget sets starts and stops on what ever the lcl supports or what ever I can read on the internet. I have no C/C++ experience that I can rely on to draw my own conclusions from the source so I can only rely on the community to help tackle the problem on those widget sets. So far in this forums the interest is very low it comes up once or twice a year as a problem but no one has managed to provide any solution not even widget set specific (including me).
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

x2nie

  • Hero Member
  • *****
  • Posts: 515
  • Impossible=I don't know the way
    • impossible is nothing - www.x2nie.com
Re: Flying panel/toolbar/form (like Office toolbar)
« Reply #11 on: September 18, 2013, 07:29:27 pm »
Hi, taazz...
I am unlucky to find that (mustapeak dropdownform). Would you like to attach them here or share with me?
I found the download link (http://www.downloadatoz.com/software-development_directory/drop-down-form/download.html) but nothing found to be downloaded. mustangpeak.net is curently idle. :(

----------
Anyway, about hooking the mainloop (while the popup shown) for cross platform implementation, I think I see the "tiger's tail" !
I mean, perhaps its not an exactly the solution we find, but its possible around there.

http://wiki.freepascal.org/Main_Loop_Hooks
http://forum.lazarus.freepascal.org/index.php?topic=9930.0

Unfortunatelly I didnt see the complete demo to run/to learn about how work with main loop hook .  ;D :( :( :o
« Last Edit: September 18, 2013, 07:43:46 pm by x2nie »
When you were logged in, you can see attachments.
Lazarus Github @ UbuntuCinnamon-v22.04.1 + LinuxMintDebianEdition5

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Flying panel/toolbar/form (like Office toolbar)
« Reply #12 on: September 18, 2013, 07:47:32 pm »
from a quick look around the wiki article it is not the same thing as subclassing in windows. In windows using subclassing you replace the main loop with your own procedure and if the need arises then you call the old one, what main loop hook is describing is a way to add something along the lines of an extra event handler with no control on when the old code is to be executed. It is a half baked solution to address a wide range of uses but it fails to address a number of problems including the one we discuss.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4468
  • I like bugs.
Re: Flying panel/toolbar/form (like Office toolbar)
« Reply #13 on: September 18, 2013, 10:05:38 pm »
Let me try to explain the popupParent and PopupMode properties. Popupmode has 3 values pmNone is the default and means none popup logic at all, pmExplicit means that the popup parent is defined by the popupParent property, pmAuto means that the form will always be in popup mode and the popupParent will be automatically chosen in which case most of the times is the application main form.

This is completely new to me although I develop some other parts of Lazarus.

The help info box for PopupMode says:
  Defines where popup menus are shown.
which is apparently wrong then.

There is nothing to select for popupParent in Object Inspector.

This feature is kind of competing with FormStyle property. It has been already extended with fsSystemStayOnTop. It could be extended also with fsPopupStayOnTop of similar.

I copied a component palette pages popup window from Codetyphon to Lazarus (it has been modified a lot since). Codetyphon guys could not make it close when the popup-button is clicked second time and the window is already open, and neither could I. If someone finds a solution, please send a patch.
This popup has another problem: It does not close when focus moves directly to another application. It closes only if a part of IDE is clicked.
This can be solved by registering an application event handler.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Flying panel/toolbar/form (like Office toolbar)
« Reply #14 on: September 19, 2013, 07:45:53 am »

This is completely new to me although I develop some other parts of Lazarus.

The help info box for PopupMode says:
  Defines where popup menus are shown.
which is apparently wrong then.

I guess you mean the info box on the object inspector which I have it hidden so if it does then I agree.
EDIT
Out of curiosity I enabled the info box on the inspector and in my installation the only think that I see when the popupMode or popupParent is selected is one line on top that reads "Package LCLBase" nothing else is provided I'm guessing that you are using a trunc version or something is wrong with my installation.

There is nothing to select for popupParent in Object Inspector.

Really? On my 1.0.10 lazarus I can select any form in the project as a popupParent.

This feature is kind of competing with FormStyle property. It has been already extended with fsSystemStayOnTop. It could be extended also with fsPopupStayOnTop of similar.

Im guessing this is for delphi compatibility personally I do not mind but it could probably only represent the popupMode property and I think that it is cleaner to leave as it is since the internal z Order of forms does not click for me as a form style value.

I copied a component palette pages popup window from Codetyphon to Lazarus (it has been modified a lot since). Codetyphon guys could not make it close when the popup-button is clicked second time and the window is already open, and neither could I. If someone finds a solution, please send a patch.
This popup has another problem: It does not close when focus moves directly to another application. It closes only if a part of IDE is clicked.
This can be solved by registering an application event handler.

The idea of popup property pair is to set the z order it have never supported any close logic this is something the developer of the application should decide upon and code as it should. I see no need to auto close a flying toolbar for example when the application looses focus although I did expect at first that the focused form will get a lost focus event when the application changed I quickly found out and used the Application.AddOnDeactivateHandler for my needs.

I do not have any idea on what the "component palette pages popup window" is, although I have used codeTyphoon for a sort period of time when I was starting I can't visualize what you are talking about or where to find it in lazarus 1.0.10.
« Last Edit: September 19, 2013, 08:05:13 am by taazz »
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

 

TinyPortal © 2005-2018