home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 May / Pcwk0597.iso / borland / ib / setups / intrabld / data.z / CONTROLS.CC < prev    next >
Text File  |  1996-12-11  |  7KB  |  182 lines

  1. /****************************************************************************\
  2. *                                                                            *
  3. * Controls.cc  --  IntraBuilder Custom Controls                              *
  4. *                                                                            *
  5. * There are several types of controls in this file:                          *
  6. *                                                                            *
  7. * Select Controls                                                            *
  8. *                                                                            *
  9. *    FieldSelect()  - options come from table field                          *
  10. *    FileSelect()   - options come from table field                          *
  11. *                                                                            *
  12. * ListBox Controls                                                           *
  13. *                                                                            *
  14. *    FieldListBox() - options come from table field                          *
  15. *    FileListBox()  - options come from table field                          *
  16. *                                                                            *
  17. * Button Controls                                                            *
  18. *                                                                            *
  19. *    ClientBackButton() - Move back a page on the client                     *
  20. *    ServerBackButton() - Move back a form on the server                     *
  21. *                                                                            *
  22. * HTML Controls                                                              *
  23. *                                                                            *
  24. *    CenterHTML()     - Display HTML text centered                           *  
  25. *    GeneratedHTML()  - Display generated by IntraBuilder text               *
  26. *                                                                            *
  27. * Updated 10/04/96 by IntraBuilder Samples Group                             *
  28. * $Revision:   1.8  $                                                        *
  29. *                                                                            *
  30. * Copyright (c) 1996, Borland International, Inc. All rights reserved.       *
  31. *                                                                            *
  32. \****************************************************************************/
  33. class FieldListBox(FormObj) extends ListBox(FormObj) custom {
  34.    with (this) {
  35.       options = "array {'table','field'}";
  36.    }
  37.  
  38.    function onServerLoad() {
  39.       this.source = eval(this.options.substring(6,this.options.length));
  40.       this.fillOptions();
  41.    }
  42.  
  43.    function fillOptions(){
  44.       this.array = new Array();
  45.       var q = new Query();
  46.       q.database = this.form.rowset.parent.database;
  47.       q.requestLive = false;
  48.       if (this.source[0].indexOf(" ") > 0 || this.source[1].indexOf(" ") > 0) 
  49.          q.sql = 'SELECT DISTINCT s."' + this.source[1] + '" from "' + this.source[0] + '" s';
  50.       else
  51.          q.sql = 'SELECT DISTINCT ' + this.source[1] + ' from ' + this.source[0];
  52.       q.active = true;
  53.       while (!q.rowset.endOfSet) {
  54.          this.array.add(q.rowset.fields[this.source[1]].value);
  55.          q.rowset.next();
  56.       }
  57.       this.options = "array this.array";
  58.    }
  59. }
  60.  
  61. class FieldSelect(FormObj) extends Select(FormObj) custom {
  62.    with (this) {
  63.       options = "array {'table','field'}";
  64.    }
  65.  
  66.    function onServerLoad() {
  67.       this.source = eval(this.options.substring(6,this.options.length));
  68.       this.fillOptions();
  69.    }
  70.  
  71.    function fillOptions(){
  72.       this.array = new Array();
  73.       var q = new Query();
  74.       q.database = this.form.rowset.parent.database;
  75.       q.requestLive = false;
  76.       if (this.source[0].indexOf(" ") > 0 || this.source[1].indexOf(" ") > 0) 
  77.          q.sql = 'SELECT DISTINCT s."' + this.source[1] + '" from "' + this.source[0] + '" s';
  78.       else
  79.          q.sql = 'SELECT DISTINCT ' + this.source[1] + ' from ' + this.source[0];
  80.       q.active = true;
  81.       while (!q.rowset.endOfSet) {
  82.          this.array.add(q.rowset.fields[this.source[1]].value);
  83.          q.rowset.next();
  84.       }
  85.       this.options = "array this.array";
  86.       if (((this.dataLink+"~") == "~") && (this.array.length > 0))
  87.          this.value = this.array[0];
  88.    }
  89. }
  90.  
  91. class FileListBox(FormObj) extends ListBox(FormObj) custom {
  92.    with (this) {
  93.       options = 'array {"*.*"}';
  94.    }
  95.  
  96.    function onServerLoad()
  97.    {
  98.       this.source = eval(this.options.substring(6,this.options.length));
  99.       this.fillOptions();
  100.    }
  101.  
  102.    function fillOptions()
  103.    {
  104.       var a = new Array();
  105.       this.files = new Array();
  106.       a.dirExt(this.source[0]);
  107.       for (var i = 0; i<(a.length/9); i++)
  108.          if (a[i,0].substring(0,9) != "Backup of")
  109.             this.files.add(a[i,0]);
  110.       this.files.sort();
  111.       this.options = "array this.files";
  112.    }
  113. }
  114.  
  115. class FileSelect(FormObj) extends Select(FormObj) custom {
  116.    with (this) {
  117.       options = 'array {"*.*"}';
  118.    }
  119.  
  120.    function onServerLoad()
  121.    {
  122.       this.source = eval(this.options.substring(6,this.options.length));
  123.       this.fillOptions();
  124.    }
  125.  
  126.    function fillOptions()
  127.    {
  128.       var a = new Array();
  129.       this.files = new Array();
  130.       a.dirExt(this.source[0]);
  131.       for (var i = 0; i<(a.length/9); i++)
  132.          if (a[i,0].substring(0,9) != "Backup of")
  133.             this.files.add(a[i,0]);
  134.       this.files.sort();
  135.       this.options = "array this.files";
  136.       if (((this.dataLink+"~") == "~") && (this.files.length > 0))
  137.          this.value = this.files[0];
  138.    }
  139. }
  140.  
  141. class GeneratedHTML(FormObj) extends HTML(FormObj) custom {
  142.    with (this) {
  143.       height = 1;
  144.       width = 70;
  145.       color = "black";
  146.       fontBold = false;
  147.       text = {||"<ADDRESS>Generated by IntraBuilder on " + new Date() + "</ADDRESS>"};
  148.    }
  149. }
  150.  
  151. class CenterHTML(FormObj) extends HTML(FormObj) custom {
  152.    with (this) {
  153.       alignVertical = 1;
  154.       alignHorizontal = 1;
  155.       text = "CenterHTML";
  156.    }
  157.  
  158. }
  159.  
  160. class ServerBackButton(FormObj) extends Button(FormObj) custom {
  161.    with (this) {
  162.       width = 10.5;
  163.       text = "Back";
  164.       onServerClick = {;form.close()};
  165.    }
  166.  
  167. }
  168.  
  169. class ClientBackButton(FormObj) extends Button(FormObj) custom {
  170.    with (this) {
  171.       width = 10.5;
  172.       text = "Back";
  173.       onClick = class::ClientBackButton1_onClick;
  174.    }
  175.  
  176.  
  177.    function ClientBackButton1_onClick()
  178.    {
  179.       history.back();
  180.    }
  181. }
  182.