Advertisement
idsystems

CPP_RAD_Ejercicio52

Jun 21st, 2012
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.53 KB | None | 0 0
  1. /* ej52_ToolBarIncrustada
  2. Ejemplo de como poner una toolbar junto con Coolbar */
  3. #include <radc++.h>
  4.  
  5. Form  form1("Cool Bar con Toolbar - RAD C++ Ejemplo");
  6. //create a coolbar
  7. CoolBar cool(AUTO_ID,form1);
  8.  
  9. /*
  10.     NOTE:
  11.     If you need to add a toolbar to a coolbar control, you will have to follow:
  12.     1.first we create a new form with no style
  13.     2.then create a toolbar and add to the newly created form
  14.     3.then add this new form to coolbar
  15. */
  16. //Create another form with no style, we will add toolbar to this form
  17. Form form2("",0,0,200,40,RCP_NONE,true,true,false,false,false,form1,true);
  18. //create toolbar as child of form2 which has no borders and style
  19. ToolBar tools(AUTO_ID,form2);
  20. //create toolbar button objects to track clicks
  21. ToolBarItem btn_exit, btn_about;
  22.  
  23. //one more object for coolbar
  24. Track trk(AUTO_ID,0,0,100,20,form1,30);
  25.  
  26. //main form procedure
  27. FormProcedure mproc(FormProcArgs);
  28. //procedure for the child form containing toolbar
  29. FormProcedure cproc(FormProcArgs);
  30.  
  31.  
  32. rad_main()
  33.  
  34.     form1.procedure = mproc;
  35.     form2.procedure = cproc;
  36.  
  37.     //create iconlist for toolbar
  38.     IconList icl(RCP_SMALL);
  39.     //add some icons to icon list
  40.     icl.add(Icon::Icon(IDI_APPLICATION));
  41.     icl.add(Icon::Icon(IDI_EXCLAMATION));
  42.     icl.add(Icon::Icon(IDI_HAND));
  43.     icl.add(Icon::Icon(IDI_QUESTION));
  44.  
  45.     //attach iconlist with toolbar        
  46.     tools.setIconList(icl);
  47.    
  48.     //show text with icons
  49.     tools.captions=true;
  50.     //don't push icons to next line when not enough space
  51.     tools.wrapable=false; //test compile after removing this line and decrease form width
  52.    
  53.    
  54.     //add buttons to toolbar
  55.     tools.add("Item 1",0,AUTO_ID); //second argument is icon id in iconlist
  56.     tools.add("Item 2",1,AUTO_ID);
  57.     btn_exit =tools.add("Salida"  ,2,AUTO_ID);
  58.     btn_about=tools.add("Acerca" ,3,AUTO_ID);
  59.    
  60.     //add the form2 which had not style, to coolbar so that toolabr remains in place properly
  61.     cool.add("",form2);
  62.     //add track to coolbar
  63.     cool.add("",trk);
  64.  
  65. rad_end()
  66.  
  67.  
  68. //implementation of forms' procedures
  69. FormProcedure cproc(FormProcArgs) {
  70.    
  71.     //forward toolbar commands to form1 so that it can take action
  72.     FORWARD_COMMANDS(form1);
  73.        
  74.     //adjust toolbar properly when form is resized
  75.     ON_RESIZE()
  76.         tools.adjust();
  77.            
  78.     return 0;
  79. }
  80. FormProcedure mproc(FormProcArgs) {
  81.     ON_CLOSE() Application.close();
  82.    
  83.     ON_COMMAND_BY(btn_exit)
  84.         Application.close();
  85.    
  86.     ON_COMMAND_BY(btn_about)
  87.         form1.infoBox("RAD C++ Coolbar y Toolbar Ejemplo.");
  88.    
  89.     //adjust coolbar properly when form is resized
  90.     ON_RESIZE()
  91.         cool.adjust();  
  92.    
  93.     return 0;
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement