Ecere SDK/eC Forums • View topic - [solved]ProgressBar and Page control




Ecere SDK/eC Forums

Ecere Developers Community

[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.

[solved]ProgressBar and Page control

Postby samsam598 » Wed Sep 07, 2011 8:09 am

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.
samsam598
 
Posts: 208
Joined: Thu Apr 14, 2011 9:44 pm

Re: ProgressBar and Page control

Postby jerome » Wed Sep 07, 2011 11:36 am

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
jerome
Site Admin
 
Posts: 623
Joined: Sat Jan 16, 2010 11:16 pm

Re: ProgressBar and Page control

Postby samsam598 » Wed Sep 07, 2011 8:01 pm

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
samsam598
 
Posts: 208
Joined: Thu Apr 14, 2011 9:44 pm

Re: ProgressBar and Page control

Postby jerome » Wed Sep 07, 2011 8:33 pm

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
jerome
Site Admin
 
Posts: 623
Joined: Sat Jan 16, 2010 11:16 pm


Return to GUI Toolkit & 2D Graphics

Who is online

Users browsing this forum: No registered users and 4 guests

cron