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 » U++ Library support » TabCtrl » Missing API for what I need to do?
Missing API for what I need to do? [message #14163] Sat, 16 February 2008 00:34 Go to next message
jlfranks is currently offline  jlfranks
Messages: 55
Registered: May 2007
Location: Houston, TX, USA
Member
I have a TabCtrl populated with five tabs using
TabCtrl::Item& Add(Ctrl& slave, const char *text)

We need a special behavior for the control that happens to
be index 4. I sense the tab Action with a callback. I don't
know which tab is selected except by index. So, my magic
number 4 is supposed to be related to the special object that requires additional handling. The problem is that I have
no way to verify that in the callback. There seems to be no
way to get at the slave control and make a comparison to
the control of interest for special handling.

If the order of the tab pages change (other programmers, etc.),
callback will be doing the wrong thing. There seems to be no
way to determine that the current selected item is the one of interest.

Somehow, I expected to have an API that I could get at the
slave object, test it, and perhaps apply special handling if
it is the object of interest.

Is there some way of doing this with the API already in place?

Re: Missing API for what I need to do? [message #14181 is a reply to message #14163] Mon, 18 February 2008 11:04 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
I haven't actually tested this, but from the code it looks like it should work (specialctrl is obviously the one on tab 4).
void TabChange()
{
   if (specialctrl.IsVisible())
       // Tab 4 selected
}

It is a bit of a bodge though, adding Item::GetSlave would be better.
Re: Missing API for what I need to do? [message #14203 is a reply to message #14163] Tue, 19 February 2008 23:46 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 11713
Registered: November 2005
Ultimate Member
jlfranks wrote on Fri, 15 February 2008 18:34


I don't
know which tab is selected except by index.



void TabCtrl::Set(int i);
int TabCtrl::Get() const;

Mirek
Re: Missing API for what I need to do? [message #14723 is a reply to message #14203] Tue, 11 March 2008 06:19 Go to previous messageGo to next message
jlfranks is currently offline  jlfranks
Messages: 55
Registered: May 2007
Location: Houston, TX, USA
Member
Pardon late reply -- broke my leg ...

This API: void TabCtrl::Set(int i);
int TabCtrl::Get() const;

is insufficient to determine what the object is. I can't
rely on magic numbers (index) to determine what the object
really is. I need to get the object itself to determine if
it really is the one of interest.

It is insufficient because in one part of the code the tabctrl
is setup with items in a certain order. In another far removed
piece of code we need to take action based on a particular
Item (object) being selected. There is no guarantee that over
time that the index (magic number) really points to the item
of interest because some other programmer could have added
more tabs (Items) or decided to change the order of the tabs.

Only the underlying object (slave ctrl) can tell us if this is
really the control of interest.

--jlf
Re: Missing API for what I need to do? [message #14724 is a reply to message #14181] Tue, 11 March 2008 06:47 Go to previous messageGo to next message
jlfranks is currently offline  jlfranks
Messages: 55
Registered: May 2007
Location: Houston, TX, USA
Member
This does in fact work. I've just tried this.

Thank you for the suggestion.

--jlf
Re: Missing API for what I need to do? [message #15062 is a reply to message #14724] Thu, 27 March 2008 22:10 Go to previous messageGo to next message
zsolt is currently offline  zsolt
Messages: 576
Registered: December 2005
Location: Budapest, Hungary
Contributor
I was unable to use IsVisible()...

It would be very useful in some cases to be able to identify the control sitting in a tab.

I would add a line to the public interface of TabCtrl::Item class:
		Ctrl*          GetCtrl()                        { return slave; }


Are there any barriers to do this?
Re: Missing API for what I need to do? [message #15063 is a reply to message #15062] Thu, 27 March 2008 23:28 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 11713
Registered: November 2005
Ultimate Member
zsolt wrote on Thu, 27 March 2008 17:10

I was unable to use IsVisible()...

It would be very useful in some cases to be able to identify the control sitting in a tab.

I would add a line to the public interface of TabCtrl::Item class:
		Ctrl*          GetCtrl()                        { return slave; }


Are there any barriers to do this?


Nope.

Added (and in const version too...)

Mirek
Re: Missing API for what I need to do? [message #15064 is a reply to message #15063] Fri, 28 March 2008 00:14 Go to previous messageGo to next message
zsolt is currently offline  zsolt
Messages: 576
Registered: December 2005
Location: Budapest, Hungary
Contributor
Thanks!
Re: Missing API for what I need to do? [message #15823 is a reply to message #15063] Thu, 08 May 2008 21:40 Go to previous messageGo to next message
zsolt is currently offline  zsolt
Messages: 576
Registered: December 2005
Location: Budapest, Hungary
Contributor
I have tried your changes, but they are not working.

The problem is, that in your code you return ctrl instead of slave, but ctrl member seems to be used only by some dead code in TabCtrl.

Could you change it to slave? Or add a new GetSlave() method returning slave?

Maybe it would be useful to remove ctrl member also.

[Updated on: Thu, 08 May 2008 21:41]

Report message to a moderator

Re: Missing API for what I need to do? [message #15915 is a reply to message #15823] Thu, 15 May 2008 22:41 Go to previous message
zsolt is currently offline  zsolt
Messages: 576
Registered: December 2005
Location: Budapest, Hungary
Contributor
What about this topic? Here is the patch:

Index: TabCtrl.h
===================================================================
--- TabCtrl.h	(revision 254)
+++ TabCtrl.h	(working copy)
@@ -47,6 +47,8 @@
 		Item&          Enable(bool _en = true);
 		Item&          Disable()                        { return Enable(false); }
 		bool           IsEnabled() const                { return enabled; }
+		Ctrl          *GetSlave()                       { return slave; }
+		const Ctrl    *GetSlave() const                 { return slave; }
 		Ctrl          *GetCtrl()                        { return ctrl; }
 		const Ctrl    *GetCtrl() const                  { return ctrl; }
 
Previous Topic: TabDlg callback when another Tab is selected?
Next Topic: TabCtrl feature request + patch
Goto Forum:
  


Current Time: Sat Feb 23 08:24:40 CET 2019

Total time taken to generate the page: 0.00850 seconds