[solved]ProgressBar and Page control

General help with the Ecere Cross Platform GUI toolkit: Window, common controls, events, etc.
Help with the 2D Graphics library: Surface, Display, Bitmap, Font and others.
Post Reply
samsam598
Posts: 212
Joined: Thu Apr 14, 2011 9:44 pm

[solved]ProgressBar and Page control

Post by samsam598 »

Greetings!I have a couple of questions here:

1.For ProgressBar ,in which event and what property/method can I use to update the status(progress)?Please help.

2.Is there an control act as the same as Tab control or Page control or TabPage control in other oop GUI?I think the answer is yes since I noticed the IDE does have made use of such control.How can I use it?Please help.

Thanks and best regards,
Sam
Last edited by samsam598 on Thu Sep 08, 2011 12:11 am, edited 1 time in total.
jerome
Site Admin
Posts: 608
Joined: Sat Jan 16, 2010 11:16 pm

Re: ProgressBar and Page control

Post by jerome »

Hi Sam,

I've tried to answer both questions in a code snippet:

Code: Select all

import "ecere"
 
class MainDialog : Window
{
   text = "Tab Sample";
   nativeDecorations = true;
   borderStyle = sizable;
   background = activeBorder;
   hasMaximize = true;
   hasMinimize = true;
   hasClose = true;
   size = { 640, 480 };
 
   TabControl tabControl { this, anchor = { left = 0, top = 0, right = 0, bottom = 0 } };
   Tab1 tab1Form { tabControl = tabControl };
   Tab2 tab2Form { tabControl = tabControl };
}
 
class Tab1 : Tab
{
   text = "Tab 1";
   int p;
 
   Timer timer1
   {
      this, delay = 0.01;
      bool DelayExpired()
      {
         if(p < 1000)
            progressBar1.progress = ++p;
         return true;
      }
   };
 
   bool OnCreate()
   {
      timer1.started = true;
      return true;
   }
 
   Button button1 { this, text = "button1" };
   ProgressBar progressBar1 { this, text = "progressBar1", range = 1000 };
};
 
class Tab2 : Tab
{
   text = "Tab 2";
 
   EditBox editBox1 { this, text = "editBox1" };
};
 
MainDialog dialog { };
The tab control is 'TabControl', and for defining the individual tabs or pages you create a class that derives from 'Tab'. Only one tab is 'created' at one time (See how the timer updating the progress bar stops when you switch tabs).

The progress bar's progress property is called 'progress', and it is a uint that ranges from 0 to the 'range' property that you can set to any value you want. range defaults to 100. You can update it from any event or any other piece of code that makes sense for you in your program.

I'll add the code snippet to the SDK's gui samples =)

Thanks,

Jerome
samsam598
Posts: 212
Joined: Thu Apr 14, 2011 9:44 pm

Re: ProgressBar and Page control

Post by samsam598 »

Thanks Jerome,got it!

Code: Select all

 
      Tab1 tab1Form { tabControl = tabControl };   
      Tab2 tab2Form { tabControl = tabControl };   
 
I am a bit lost with the code assignment tabControl=tabControl.How can we do that?Could you please clarify?
Appreciate.

Regards,
Sam
jerome
Site Admin
Posts: 608
Joined: Sat Jan 16, 2010 11:16 pm

Re: ProgressBar and Page control

Post by jerome »

Hi Sam,

Sorry, I know it's a bit confusing.

The 'Tab' class has a 'tabControl' property, which you set to a parent TabControl.
I just so happen to name the parent control (for obvious reasons) 'tabControl' as well.

So tabControl = tabControl means you set the Tab::tabControl property to the TabControl instance Form1::tabControl.

I realize this causes confusion, and it gave me trouble in the past as well. I've also just realized the Tab can 'watch' its parent property instead and achieve the same effect. I've updated the GUI toolkit code, and the sample code as well in this commit to read like this:

Code: Select all

   TabControl tabControl { this, anchor = { left = 0, top = 0, right = 0, bottom = 0 } };
   Tab1 tab1Form { tabControl };
   Tab2 tab2Form { tabControl };
All the best,

Jerome
Post Reply