Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Developing U++ » UppHub » PopEasy
PopEasy [message #36489] Fri, 01 June 2012 16:33 Go to next message
Lance is currently offline  Lance
Messages: 380
Registered: March 2007
Senior Member
I am working on a small utility that may help make Popup easier in many situations.

It seeks to handle some situations which DropChoice, DropTree and DropGrid either don't take care of or can not be used in with ease.

It aims to support auto-popup, auto-select, and auto-completion. Attached example shows auto-popup and auto-select. auto-completion is not currently supported. I am still debating on the mechanism to communicate auto-completion information from the popup to the owner (or main) ctrl.

For an brief idea of what PopEasy is, please try attached example. It's still very primitive, but please feel free to give your input.

Some concrete PopUp class similar to DropTree and DropChoice will be added for convenience. They are not currently present though.

Thanks,

Lance

[Updated on: Sun, 03 June 2012 03:19]

Report message to a moderator

Re: PopEasy [message #36494 is a reply to message #36489] Sat, 02 June 2012 14:25 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3268
Registered: August 2008
Senior Veteran
Hello Lance

I have a problem with POSITION. It is in PopEasy.h and it is not declared.


Best regards
Iñaki
Re: PopEasy [message #36496 is a reply to message #36494] Sat, 02 June 2012 19:51 Go to previous messageGo to next message
omari is currently offline  omari
Messages: 243
Registered: March 2010
Experienced Member
Hello Lance,

I have do same thing similar in an old project

to facilitate the work, I propose to add an EditField in the same window as the ArrayCtrl.

zip attached explain my proposal.

Regards

Omari.


regards
omari.
Re: PopEasy [message #36497 is a reply to message #36496] Sun, 03 June 2012 01:16 Go to previous messageGo to next message
Lance is currently offline  Lance
Messages: 380
Registered: March 2007
Senior Member
Thank you both. I will have a quick examine.
Re: PopEasy [message #36498 is a reply to message #36497] Sun, 03 June 2012 01:28 Go to previous messageGo to next message
Lance is currently offline  Lance
Messages: 380
Registered: March 2007
Senior Member
Hi Koldo:

it's in CtrlCore.h

public:
	enum StateReason {
		FOCUS      = 10,
		ACTIVATE   = 11,
		DEACTIVATE = 12,
		SHOW       = 13,
		ENABLE     = 14,
		EDITABLE   = 15,
		OPEN       = 16,
		CLOSE      = 17,
		POSITION   = 100,
		LAYOUTPOS  = 101,
	};


Not sure if it's because of a namespace issue. I'll do a test compilation in Ubuntu in a while. WithPopUp<> inherits from Ctrl or its derivative, so POSITION should be visible to it. Anyway, it use explicit Ctrl::POSITION or Ctrl:::StateReason::POSITION silence the compiler, please let me know.
Re: PopEasy [message #36499 is a reply to message #36498] Sun, 03 June 2012 01:45 Go to previous messageGo to next message
Lance is currently offline  Lance
Messages: 380
Registered: March 2007
Senior Member
Hi Omari:

I separate the Edit Ctrl (main ctrl) and the pop up on purpose.

In the above example, the Edits use the PopUp but don't contain it. The share a single instance of PopUp. If the list is static (no auto filtering) as in your case, this can save some memory space.

Also there are other concerns. The EditField could be a multi-line edit (LineEdit) or even a RichEdit. As long as they talk to each other through some simple and complete interface (normal functions and virtual functions and callbacks).

The PopUp can be a TreeCtrl, a ArrayCtrl, a GridCtrl, or a combination of many of them.

I am not familiar with Upp, but EditField might be a better option than EditString. There a lots of details waiting to be decided. Please do have a look at the code and give me some suggestion.
Re: PopEasy [message #36500 is a reply to message #36499] Sun, 03 June 2012 03:26 Go to previous messageGo to next message
Lance is currently offline  Lance
Messages: 380
Registered: March 2007
Senior Member
Hi Koldo:

Yes, I encountered the same problem in g++. It has been fixed.

Here is a screenshot.

index.php?t=getfile&id=3764&private=0
Re: PopEasy [message #36512 is a reply to message #36500] Sun, 03 June 2012 22:56 Go to previous messageGo to next message
Lance is currently offline  Lance
Messages: 380
Registered: March 2007
Senior Member
Main motivation:

In database application, a typical requirement we frequently have is some kind of Ctrl (or group of Ctrls) that do key-value conversion. Eg, you (or users of your application) will key in some text in certain area intended for an inventory item, and your application can search database in whatever way you decided for all matching inventory items; these items are subsequently presented to user. He/she may select one either with key stroke or mouse, or he/she may keep on typing until the list is short enough. And when a choice is finally made, a user friendly text will be displayed and the associated iventory item id (of integral type) is be provided to the application for subseqent processing.

DropGrid with search-hide-row is a closest match. I have been using it extensively. DropGrid, however, like DropChoice, DropTree, will own the keyboard focus in its session. This make editing not always as natural as we would like. For example, I need to do some interesting things with all inventory items containing "fatastic", one at a time. Let's say I have 10 items containing this text. With DropGrid, I need to key in "fatasic" for 10 times. Why couldn't I just type it once, copy it in the clipboard, and paste it for the subsequent 9 times? I might be wrong in DropGrid's not accepting Ctrl-V, but you'll definitely find situations you would rather work with a real edit ctrl, be it EditField derivative, EditLine, or RichEdit.

For that purpose, the popup should not take focus away from the main ctrl (the ctrl the popup will work for. In Ctrl::PopUp(...), it's called the *owner*). I did some experiment, and fixed some issue associated with that.

One of it happens when the main window is resized or moved. Resize'ing or move'ing will not trigger main's lost-focus event, we end up have a popup detached from its owner. BTW, theide's CodeCompletion, which is the best among the open-source ones (second only to Visual Studio and possibly a couple of other commercial ides), uses the same approach that would-be PopEasy uses: a non-focus popup with the focused editor. Theide's popup will no respond to size/move. If you bring up a PopUp and then resize or move theide, you'll found the popup detached from the location it's giving options for. Anyway, after some research, I find it can be handled nicely with UPP's built-in capability: just use the State virtual method.

Another issue I encountered is a visibility issue. I use TabBarCtrl to provide a multi-tab user interface similar to FireFox. If I bring up a popup for a ctrl and switch to another tab, the popup becomes detached and clueless as its owner remains focused and doesn't have a size/position change. To fix this issue, I decide to unpop the popup when its owner becomes invisible. This is a very dubious decision because it prohibits the popup from covering its owner which is theoretically wrong. But for now, it doesn't seem to be so much a problem and promises an easy fix.

[Updated on: Sun, 03 June 2012 23:23]

Report message to a moderator

Re: PopEasy [message #36520 is a reply to message #36512] Mon, 04 June 2012 15:34 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3268
Registered: August 2008
Senior Veteran
Hello Lance

Now it works for me Smile.

It is interesting. Please upload it to Bazaar and maintain us informed about its evolution with samples.


Best regards
Iñaki
Re: PopEasy [message #36522 is a reply to message #36520] Mon, 04 June 2012 18:01 Go to previous messageGo to next message
Lance is currently offline  Lance
Messages: 380
Registered: March 2007
Senior Member
Thanks, Koldo.

I will when it's in a better shape.
Re: PopEasy [message #36543 is a reply to message #36522] Wed, 06 June 2012 17:29 Go to previous messageGo to next message
Lance is currently offline  Lance
Messages: 380
Registered: March 2007
Senior Member
PopEasy is now in a more presentable state. See attached for a simple example with auto-popup, auto-completion, auto-selection supported.

Koldo:
I need some guidance on utf-8 support. Or should I use WString instead just like what EditField does internally?

Please PM me a password for uploading, or if you don't mind, you can also upload for me.
Re: PopEasy [message #36544 is a reply to message #36543] Wed, 06 June 2012 18:17 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3268
Registered: August 2008
Senior Veteran
Hello Lance

It works for me in XP and Ubuntu. PopList follows frenetically the main window Smile.

I do not understand the UTF-8 problem: Adding accented words in the company list the program uses them perfectly.

GCC hates Ctrl::StateReason::POSITION. All compilers prefer Ctrl::POSITION.

Backspace to remove the auto-completed suffix could be a good feature.

I have seen that PopList is apart. One serve for all EditCust fields Smile.


Best regards
Iñaki
Re: PopEasy [message #36545 is a reply to message #36544] Wed, 06 June 2012 19:00 Go to previous messageGo to next message
Lance is currently offline  Lance
Messages: 380
Registered: March 2007
Senior Member
Hi Koldo:

Thanks for taking your time to actually looking at the code.

By full utf-8 support, I mean in suffix computation, current implementation may mistaken part of a utf-8 character as a independent character. I don't know utf-8 very well, I just assume it. Let's say 2 characters in certain charset share the first 2 bytes in common, only differ in the 3rd characters, current implementation may think they bare some resemblance even though they should be considered different for suffix calculation purpose. To avoid that kind of mistake, we need to advance character by character, instead of byte by byte as currently employed. Or maybe it's easier to do with WString. I guess there is a reason why EditField should use WString internally

GCC hates Ctrl::StateReason::POSITION. All compilers prefer Ctrl::POSITION.

Will fix it right away.

I have seen that PopList is apart. One serve for all EditCust fields

And one can easily extend PopListBase to retrieve live data from a database. I find it's easier in most cases than to cache all customer lists and listen to subseqent add/delete/edit to the underlying data and update the cached list.
Re: PopEasy [message #36548 is a reply to message #36545] Thu, 07 June 2012 04:48 Go to previous message
Lance is currently offline  Lance
Messages: 380
Registered: March 2007
Senior Member
GCC hates Ctrl::StateReason::POSITION. All compilers prefer Ctrl::POSITION.

Backspace to remove the auto-completed suffix could be a good feature.


Fixed these two. The latter for PopList only though.

Previous Topic: MediaPlayer compiler error
Next Topic: AngelScript - AngelCode Scripting Library
Goto Forum:
  


Current Time: Tue Oct 26 14:32:56 CEST 2021

Total time taken to generate the page: 0.01202 seconds