Ecere SDK/eC Forums
https://ecere.org/community/
Print view

[solved]ProgressBar and Page control
https://ecere.org/community/viewtopic.php?f=5&t=181
Page 1 of 1
Author:  samsam598 [ Wed Sep 07, 2011 8:09 am ]
Post subject:  [solved]ProgressBar and Page control

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
Author:  jerome [ Wed Sep 07, 2011 11:36 am ]
Post subject:  Re: ProgressBar and Page control

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
Author:  samsam598 [ Wed Sep 07, 2011 8:01 pm ]
Post subject:  Re: ProgressBar and Page control

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
Author:  jerome [ Wed Sep 07, 2011 8:33 pm ]
Post subject:  Re: ProgressBar and Page control

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
All times are UTC-05:00 Page 1 of 1