Ecere SDK/eC Forums • View topic - [Solved]How can I use a DataBox




Ecere SDK/eC Forums

Ecere Developers Community

[Solved]How can I use a DataBox

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]How can I use a DataBox

Postby samsam598 » Tue Aug 23, 2011 5:15 am

Is there any introduction to the DataBox?Just an easy reference should be fine.

Thanks.
Last edited by samsam598 on Thu Sep 08, 2011 12:29 am, edited 1 time in total.
samsam598
 
Posts: 208
Joined: Thu Apr 14, 2011 9:44 pm

Re: How can I use a DataBox

Postby jerome » Tue Aug 23, 2011 11:01 am

Hi Sam,

Right now DataBox is a bit messy, its main purpose is for internal use, e.g. within the ListBox.
To use it outside as a generic type editor, you should use the SavingDataBox control (which inherit from DataBox). There is a code snippet in this thread.

Please ask if you have any specific questions.

Regards,

Jerome
jerome
Site Admin
 
Posts: 623
Joined: Sat Jan 16, 2010 11:16 pm

Re: How can I use a DataBox

Postby samsam598 » Tue Aug 23, 2011 8:16 pm

Thanks Jerome,

Any introduction on Menu,ToolBar and StatusBar?For Menu I can study from examples,but still don't quite understand what MenuPlacement is for.

Thanks for the help.
samsam598
 
Posts: 208
Joined: Thu Apr 14, 2011 9:44 pm

Re: How can I use a DataBox

Postby jerome » Tue Aug 23, 2011 9:46 pm

Hi Sam,

We're still missing good tutorials for these. And I hope to write a chapter in the Tao full of good knowledge about all that. You are most welcome to share your learning examples on the forums as you learn, and I can later make use of that when writing the Tao or assembling new samples.

We don't have any toolbar control at this point, even the IDE is still missing a toolbar.
We have a few applications however that implemented a toolbar. Checkout EDE (Our Ecere Desktop Environment - a file explorer for now) which implements a ToolBar class.

We should integrate the toolbar within Ecere, and the IDE :)

StatusBar is quite simple. You just set the 'hasStatusBar' property of your form to true. Then you can define StatusField objects (which have width and a 'text' property for setting their contents), and you use StatusBar::AddField to add them to your StatusBar. You can clear all the fields with ClearField. You can check sdk/ide/src/ide.ec for examples.

Menus are quite powerful. You can create a stand alone menu by instantiating the PopupMenu class, or a window menu by setting your form 'hasMenuBar' to true. Both of these inherit from the Window class, and both of them have a 'menu' property, which is meant to point to their 'Menu' object. With a window menu, a 'Menu' object is already created for you, and is accessible through the 'menu' property.

sdk/samples/guiAndGfx/mdiSample is actually a decent sample for menus. It also shows you how to do MDI type applications (however not fashionable they are these days - we need a docking/tab model in the IDE :D). I don't know if you were around in the old Windows days, but I was doing Win32 and even Windows 3.1 coding with MDI windows and the code was so horrible, it would have taken hundreds of lines of code to do something like that :) MFC was just as horrible.

So in a Menu, you can put 4 kinds of things:
1. MenuItem - an actual menu item, which can have a NotifySelect event
2. Other Menu objects - sub menus, which can contain all these 4 things again recursively
3. MenuDivider - An horizontal bar separating your menus, if at the top level of a menu bar it will bring all the next menus to the far right, as it was fashionable for Help Menus before resolutions went so big.
4. A MenuPlacement - This is a more advanced topic, it is useful for controlling the position where sub menus of child MDI windows will go. The Ecere GUI systems supports menu merging of child windows when the parent's 'mergeMenus' property is set to true (the default). The child window's menu will then be displayed together with the parent's menu, and a MenuPlacement can force an item to be placed somewhere, rather than at the end. If both the parent and the child have an 'Edit' sub menu, the items will merge together in there. A MenuPlacement is useful where you don't have any item to show in the parent menu, and don't want the menu to show when no child window is active, but you don't want to have it placed arbitrarily at the start of the parent menu either. You can check the sdk/samples/guiAndGfx/eNotepad sample for an example usage of a MenuPlacement (If you comment out the MenuPlacement, you will see the EditMenu moves to the start). You could try for fun making an MDI notepad)

Just for fun, here's a minimalistic Ecere notepad:
Code: Select all
import "ecere"
 
EditBox notepad
{
   text = "Ecere Minimalistic Notepad";
   hasClose = true;
   hasMinimize = true;
   hasMaximize = true;
   multiLine = true;
   isDocument = true;
   size = { 640, 480 };
   hasMenuBar = true;
 
   bool OnPostCreate()
   {
      Menu fileMenu { menu, "File", f };
      MenuItem { fileMenu, "Save\tCtrl+S", s, ctrlS, NotifySelect = MenuFileSave };
      MenuItem { fileMenu, "Save As...", a, NotifySelect = MenuFileSaveAs };
      return true;
   }
};
jerome
Site Admin
 
Posts: 623
Joined: Sat Jan 16, 2010 11:16 pm

Re: How can I use a DataBox

Postby jerome » Tue Aug 23, 2011 10:30 pm

Hi Sam. Just for some fun with the (Saving)DataBox and fancy datatypes (EDITED):
Code: Select all
import "ecere"
 
class ColorFun : Window
{
   text = "Fun With Colors and Data Boxes";
   background = activeBorder;
   borderStyle = sizable;
   hasMaximize = true;
   hasMinimize = true;
   hasClose = true;
   nativeDecorations = true;
   tabCycle = true;
   size = { 640, 480 };
 
   Color color;
   color = activeBorder;
   SavingDataBox colorBox
   {     
      this, size = { 116, 20 }, position = { 176, 104 }; data = &color; type = class(Color);
 
      bool NotifyChanged(bool closingDropDown)
      {
         background = color;
         return true;
      }
   };
 
   Date date;
   DateTime now;
   date = (now.GetLocalTime(), Date { now.year, now.month, now.day });
   SavingDataBox dateBox
   {     
      this, size = { 200, 20 }, position = { 376, 104 }; data = &date; type = class(Date);
   };
 
   double d;
   d = Pi;
   SavingDataBox doubleBox
   {     
      this, size = { 116, 20 }, position = { 176, 204 }; data = &d; type = class(double);
   };
}
 
ColorFun form {};


Cheers.
jerome
Site Admin
 
Posts: 623
Joined: Sat Jan 16, 2010 11:16 pm

Re: How can I use a DataBox

Postby jerome » Tue Aug 23, 2011 10:55 pm

jerome
Site Admin
 
Posts: 623
Joined: Sat Jan 16, 2010 11:16 pm

Re: How can I use a DataBox

Postby samsam598 » Wed Aug 24, 2011 1:04 am

jerome wrote:Hi Sam,

You are most welcome to share your learning examples on the forums as you learn, and I can later make use of that when writing the Tao or assembling new samples.



I am glad to do so.Is there a specific thread in the forum fit?If so,ecerers can post their code snippets there to share with each other.Also grateful for your help to move the two code snippets in the Chinese thread currently to the new/specific thread.

Btw,selecting dir when create new project will causing IDE crash.I've reported this issue in the Bug Tracker.Trust you've noticed that.
samsam598
 
Posts: 208
Joined: Thu Apr 14, 2011 9:44 pm

Re: How can I use a DataBox

Postby jerome » Wed Aug 24, 2011 3:40 am

Thanks for letting me know Sam (http://ecere.com/mantis/view.php?id=600)
It must be one of my recent fixes that broke it. I will take a look at it tomorrow.

The best thread where to post them is where you would go looking for it on the forums :)
I tried to organize the forums by topic, e.g. GUI, newtork, 3D...
So within GUI might be a good idea for any GUI sample :) Thanks!

Also if you are working on a bigger project of your own using Ecere, please tell us about it in this forum.
jerome
Site Admin
 
Posts: 623
Joined: Sat Jan 16, 2010 11:16 pm

Re: How can I use a DataBox

Postby jerome » Wed Aug 24, 2011 6:48 pm

Hi Sam, Just to let you know the New Project Dialog crash has been fixed. It was a silly omission in the last PathBox fix. Thanks for reporting it!
jerome
Site Admin
 
Posts: 623
Joined: Sat Jan 16, 2010 11:16 pm

Re: How can I use a DataBox

Postby jerome » Wed Aug 24, 2011 11:12 pm

Hi Sam,

I just committed updates that allows for the use of FilePath or DirPath in a DataBox:
Code: Select all
class FileFun : Window
{
   text = "Fun With DirPath";
   background = activeBorder;
   borderStyle = sizable;
   hasMaximize = true;
   hasMinimize = true;
   hasClose = true;
   nativeDecorations = true;
   tabCycle = true;
   size = { 640, 480 };
 
   String s;
   s = (s = new char[MAX_LOCATION], GetWorkingDir(s, MAX_LOCATION), s);
   SavingDataBox pathBox
   {     
      this, size = { 200, 20 }, position = { 376, 204 }; data = &s; type = class(DirPath);
 
      bool NotifyChanged(bool closingDropDown)
      {
         PrintLn("The user selected ", s);
         return true;
      }
   };
 
   ~FileFun()
   {
      delete s;
   }
}

Cheers,

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