Ecere SDK/eC Forums • View topic - Code Snippet06-RadioButton/CheckBox/DropBox




Ecere SDK/eC Forums

Ecere Developers Community

Code Snippet06-RadioButton/CheckBox/DropBox

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.

Code Snippet06-RadioButton/CheckBox/DropBox

Postby samsam598 » Thu Sep 15, 2011 9:58 pm

Purpose:basic usage of RadioButton,CheckBox and DropBox(ComoboBox in other GUI).
Code: Select all
 
 import "ecere"
 
class Form1 : Window
{
   text = "RadioButton/CheckBox/DropBox示例";
   background = activeBorder;
   borderStyle = fixed;
   hasMaximize = true;
   hasMinimize = true;
   hasClose = true;
   tabCycle = true;
   hasStatusBar = true;
   menu = {  };
   size = { 344, 192 };
   anchor = { horz = -143, vert = -101 };
   nativeDecorations = true;
 
   EditBox editBox1 { this, text = "editBox1",  size = { 142, 19 }, position = { 16, 56 } };
   DropBox dropBox1
   {
      this, text = "dropBox1", size = { 240, 24 }, position = { 16, 96 }; editText=false;
 
      bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
      {
         this.statusBar.text=dropBox.currentRow.string;
         return true;
      }
   };
   Button ckReadOnly
   {
      this, text = "只读", background = white, position = { 192, 56 }, isCheckbox = true;
 
      bool NotifyClicked(Button button, int x, int y, Modifiers mods)
      {
         editBox1.readOnly=button.checked;
         dropBox1.editText=!button.checked;
 
         return true;
      }
   };
   Button rdRed
   {
      this, text = "红色", size = { 58, 21 }, position = { 16, 16 }, isRadio = true;
 
      bool NotifyClicked(Button button, int x, int y, Modifiers mods)
      {
         editBox1.background=TheColor(); 
         return true;
      }
 
   };
   Button rdBlue
   {
      this, text = "兰色", size = { 64, 23 }, position = { 96, 16 }, isRadio = true;
 
      bool NotifyClicked(Button button, int x, int y, Modifiers mods)
      {
         editBox1.background=TheColor(); 
         return true;
      }
   };
   Button rdGreen
   {
      this, text = "绿色", size = { 72, 23 }, position = { 184, 16 }, isRadio = true;
 
      bool NotifyClicked(Button button, int x, int y, Modifiers mods)
      {
         editBox1.background=TheColor(); 
         return true;
      }
   };
   void Initalize()
   {
      FillDropBox();
      dropBox1.currentRow=dropBox1.firstRow;
      rdRed.checked=true; 
      ckReadOnly.checked=true;
      editBox1.background=red;
      statusBar.borderStyle=deep;
      editBox1.readOnly=true;
      dropBox1.editText=false;
 
   }
   Form1()
   {
      Initalize();
   }
 
   void FillDropBox()
   {
      int i;
 
      for(i=0;i<10;i++)
      {
         dropBox1.AddStringf("花好月圆%d",i+1);
      }
   }
 
   Color TheColor()
   {
      if(rdRed.checked) return red;
      else if(rdBlue.checked) return blue;
      else return green;
   }
}
 
Form1 form1 {};
 
                     
 
Last edited by samsam598 on Fri Sep 16, 2011 12:05 am, edited 2 times in total.
samsam598
 
Posts: 208
Joined: Thu Apr 14, 2011 9:44 pm

Re: Code Snippet06-RadioButton/CheckBox/DropBox

Postby jerome » Thu Sep 15, 2011 11:28 pm

Sam,

Just to clarify the distinction between a DropBox and a ComboBox, a ComboBox is usually a 'combo' of an Edit and a Drop box together. The Ecere dropbox supports that by setting DropBox::editText to true, and handling NotifyTextEntry, in which you will usually add the text to the DropBox, if it is valid.

Also don't forget to set tabCycle = true on those forms with controls =)

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

Re: Code Snippet06-RadioButton/CheckBox/DropBox

Postby samsam598 » Fri Sep 16, 2011 12:06 am

Thank you for the firguring out!I've updated the code.
samsam598
 
Posts: 208
Joined: Thu Apr 14, 2011 9:44 pm


Return to GUI Toolkit & 2D Graphics

Who is online

Users browsing this forum: No registered users and 4 guests

cron