May 22, 2024, 08:17:23 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Tab Control?

Started by Doc, January 31, 2006, 05:24:01 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Doc

Paul,
Is there any possibility that we may see a native tab control for Aurora?

This seems to be one of the most versatile controls for dealing with large/complex GUI's and one that I keep finding a need for in some of the stuff I do...

Part II
Whether the answer is yea or nay, does anyone have an idea of how to implement a non-native one in Aurora?

I've got a partially finished project that I started in an unrelated language that I would like to try porting to Aurora... not only does it need a speed boost, but that would give me an opportunity to do some real work while learning. :)

-Doc-

Ionic Wind Support Team

Doc,
All of the common controls will be included.  TreeView, Tab, and Slider will probably be in the next update.  The RichEdit control took up most of my time for the last one ;)
Ionic Wind Support Team

Doc


Parker

Non native as in not the windows API one? You'd have to keep a list of all the tabs and just handle the painting and tab change messages. There are a couple of things I wanted to do that requires tabs have handles and not just id slots, when there are API headers I'll try it but it may take quite a while.

Doc

QuoteNon native as in not the windows API one?

Yepper, that's what I meant. Yuk. I read through the API doc's on using the tab control and it looks pretty messy to me. But then again *everything* with the API looks messy to me!  ::)

At any rate, since Paul has the Aurora versions already scheduled, don't worry with it unless it's something you need for your own use.... I'm perfectly happy to wait. :)

Thanks,
-Doc-

Parker

The aurora controls just wrap the API controls into a class. If a functionality isn't provided by Microsoft it can't be used in Aurora.

What I meant is writing one from scratch which I'm going to do eventually, but it will probably be a long time before I start.

Ionic Wind Support Team

Quote
If a functionality isn't provided by Microsoft it can't be used in Aurora.

That is not necessarily true.  Ownerdraw controls let you provide your own drawing capability.  The button control uses this to provide colored buttons, something that is not provided by Microsoft in the stock control. Oddly enough.
Ionic Wind Support Team

Parker

Sorry, I was referring to the ability to get a tab's handle which you can't do :(

Ionic Wind Support Team

That's because the tab control is a single entity, there is no handle to get, except for the entire control that is.  The control just 'draws' the tab. Much like there isn't a separate handle for the thumb bar or arrows of a scrollbar. 

For kicks you should look at the source for Wine.  A lot of reverse engineering went into the controls to make them look and feel the same.

Ionic Wind Support Team

Ionic Wind Support Team

Here is a demo program of the tab control.  You won't be able to compile it until the next update...but I wanted to show you what will be involved.  Notice there isn't a pointer in sight ;).  That's because member classes are now constructed properly.


class TabDemo : window
{
declare OnClose(),int;
declare OnCreate(),int;
declare OnSize(int nType,int cx,int cy),int;
declare OnEraseBkgnd(),int;
CTabCtrl tab1;
}

#define TABID 2

global sub main()
{
TabDemo cp;
cp.Create(0,0,640,480,AWS_MINIMIZEBOX|AWS_MAXIMIZEBOX|AWS_SIZE|AWS_VISIBLE|AWS_SYSMENU,0,"Tab Control Test",0);
cp.EnableTabs(true);
Do{ wait(); }until cp.m_hWnd = 0;
}

TabDemo::OnCreate(),int
{
tab1.Create(0,0,640,480,AWS_BORDER|AWS_VISIBLE|AWS_TABSTOP|ATCS_TOOLTIPS|ATCS_HOTTRACK,TABID,"",this);
tab1.InsertTab(0,"Calendar");
tab1.InsertTab(1,"Trackbar");
tab1.InsertTab(2,"Progress Bar");
tab1.InsertTab(3,"Date/Time picker");
tab1.InsertTab(4,"IP Address");
//tooltips for the tabs
tab1.SetTip (0,tab1.GetTabText(0));
tab1.SetTip (1,tab1.GetTabText(1));
tab1.SetTip (2,tab1.GetTabText(2));
tab1.SetTip (3,tab1.GetTabText(3));
tab1.SetTip (4,tab1.GetTabText(4));
return true;
}

TabDemo::OnClose(),int
{
Destroy();
return true;
}

TabDemo::OnSize(int nType,int cx,int cy),int
{

rcClient = GetClientRect();
tab1.SetSize(rcClient.left,rcClient.top,rcClient.right - rcClient.left,rcClient.bottom-rcClient.top);
return true;
}

TabDemo::OnEraseBkgnd(),int
{
//returning TRUE indicates we will handle erasing the windows background
//because the tab control covers the entire client area.
return true;
}
Ionic Wind Support Team

Zen

Hey thats looking nice and tidy Paul. No pointers either, its like a dream come true ;)

Lewis

Parker

The tab control will be a nice thing to have. I'll have to look at wine too, it'll be interesting to see.

I think what I meant by handles is something like a control ID. A single tab just has an index which isn't very helpful when you have an MDI tabbed interface and tabs can be removed by closing a window, then all the windows tab references have to be updated. I'd like it better if tab ID 1 always stays as 1 and doesn't change to 2 when a tab is inserted in front of it. But I guess I've got two choices; live with it or make my own.

Zen

i suppose you dont have to make your own. Just make some subroutines to manage it how you want it too.

Lewis

Parker

I can't do that since MS doesn't provide enough functionality. Or at least not the way I want to.

Zen

What exactly is it you want to do? is this that thing you were going on about before when you were trying to get a handle to a clientarea type thing of the tab control?

Lewis

Ionic Wind Support Team

The tab control supports user data.  Just set that to the handle of the client window.  When the client window is going to close use that to match the tab...just a simple loop will do it.

In the Aurora control the two methods are SetItemData and GetItemData.
Ionic Wind Support Team

Doc

Quote from: Lewis on February 01, 2006, 03:06:39 PM
Hey thats looking nice and tidy Paul. No pointers either, its like a dream come true ;)

Lewis

I completely agree. Awesome!

-Doc-

Parker

Yeah but it's a two way system. The tab storing the window's hwnd I got fine. But I wanted to have a window store the tab's ID. Although, I suppose doing a loop wouldn't be a bad idea, just going through all the tabs.

And yes, I wanted the "client area" of a tab control because it changes based on what text size you have, whether there are images, etc. This image demonstrates what I'm looking for. Just ignore the bottom line.


Maybe that area can't be calculated and you just have to subtract a tab's height from the whole control, I know that can be done.

I actually like working with pointers. They give you more flexibility, like passing NULL instead of having to fill a new type, and dynamically allocating them.

Zen

i think the best way to do what you are doing would be to write a custom control that is basicly a subclassed tab control. That way it will be easy to use your new control and it should work on all systems.

Lewis

Parker

Urgh... no, I don't feel like doing any subclassing or owner draw. If I have to do that I'd rather write my own that has all the functionality I want.

But see this
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/tab/messages/tcm_getitemrect.asp
I can just do a simple GetSize() and subtract to get the sizes I want. Maybe I'll try once again at this tabbed MDI thing.

Zen

i didnt mean do all the owner draw stuff, basicly your own control would just hide all the nasty code that you would use to get the "client area" so to speak.

Lewis

Ionic Wind Support Team

No need to subclass with OOP.  Just derive your own class and add the functionaity you need.
Ionic Wind Support Team

Zen

whOOPs that what i mean, still not used to the terminology, does the same kind of job though.

Lewis

Ionic Wind Support Team

As for a tabbed MDI....if you look at the IDE you'll note that the tab control is only as large as the tabs itself.  Normally you don't use the blank area of a tab control for anything.  You can, and I have made other controls children of a tab, but it is not necessary.

Ionic Wind Support Team

Ionic Wind Support Team

TreeView is now done as well.
Ionic Wind Support Team