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

Code Snippet06-RadioButton/CheckBox/DropBox
http://ecere.org/community/viewtopic.php?f=5&t=196
Page 1 of 1
Author:  samsam598 [ Thu Sep 15, 2011 9:58 pm ]
Post subject:  Code Snippet06-RadioButton/CheckBox/DropBox

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 {};
 
                     
 
Author:  jerome [ Thu Sep 15, 2011 11:28 pm ]
Post subject:  Re: Code Snippet06-RadioButton/CheckBox/DropBox

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
Author:  samsam598 [ Fri Sep 16, 2011 12:06 am ]
Post subject:  Re: Code Snippet06-RadioButton/CheckBox/DropBox

Thank you for the firguring out!I've updated the code.
All times are UTC-05:00 Page 1 of 1