home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Visual Database / Visual dBase Pro v7.0 / DATA1.CAB / Utilities / Web_Wizard / Wizhtml.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1997-11-20  |  10.2 KB  |  417 lines

  1. class HTMLGet(parentObj, name) of CONTAINER(parentObj, name) custom
  2.    with (this)
  3.       left = 85
  4.       top = 70
  5.       width = 368
  6.       height = 218
  7.       metric = 6
  8.       colorNormal = "BtnFace"
  9.       borderStyle = 1
  10.       transparent = true
  11.       pageno = 0
  12.    endwith
  13.  
  14.    this.MASK = new RECTANGLE(this)
  15.    with (this.MASK)
  16.       top = 146 
  17.       width = 367
  18.       height = 70
  19.       border = false
  20.       borderStyle = 3
  21.    endwith
  22.  
  23.    this.TEXT16 = new TEXT(this)
  24.    with (this.TEXT16)
  25.       height = 14
  26.       left = 1
  27.       top = 0
  28.       width = 364
  29.       metric = 6
  30.       colorNormal = "BtnText/BtnFace"
  31.       fontSize = 8
  32.       borderstyle = 3
  33.       text = "Text"
  34.       wrap = false
  35.       pageno = 0
  36.    endwith
  37.  
  38.    this.EDITOR1 = new EDITOR(this)
  39.    with (this.EDITOR1)
  40.       height = 76
  41.       left = 0
  42.       top = 14
  43.       width = 366
  44.       metric = 6
  45.       value = ""
  46.       fontSize = 8
  47.       cuaTab = true
  48.       pageno = 0
  49.       borderStyle = 2
  50.    endwith
  51.  
  52.  
  53.    this.Display = new Text(this)
  54.    with (this.DISPLAY)
  55.       height = 56
  56.       left = 0
  57.       top = 90
  58.       width = 366
  59.       metric = 6
  60.       text = "This is a sample of the text..."
  61.       ColorNormal = 'N'
  62.       fontSize = 10
  63.       pageno = 0
  64.       borderStyle = 2
  65.       transparent = true
  66.       wrap = false
  67.    endwith
  68.  
  69.  
  70.    this.RECTANGLE3 = new RECTANGLE(this)
  71.    with (this.RECTANGLE3)
  72.       left = 228
  73.       top = 148
  74.       width = 132
  75.       height = 60
  76.       metric = 6
  77.       text = "Font"
  78.       fontSize = 8
  79.       pageno = 0
  80.    endwith
  81.  
  82.  
  83.    this.RECTANGLE2 = new RECTANGLE(this)
  84.    with (this.RECTANGLE2)
  85.       left = 110
  86.       top = 148
  87.       width = 113
  88.       height = 60
  89.       metric = 6
  90.       text = "Text Color"
  91.       fontSize = 8
  92.       pageno = 0
  93.    endwith
  94.  
  95.  
  96.    this.RECTANGLE1 = new RECTANGLE(this)
  97.    with (this.RECTANGLE1)
  98.       left = 5
  99.       top = 148
  100.       width = 99
  101.       height = 60
  102.       metric = 6
  103.       text = "Alignment"
  104.       fontSize = 8
  105.       pageno = 0
  106.    endwith
  107.    
  108.    
  109.    this.ALIGNLEFTRADIO = new RADIOBUTTON(this)
  110.    with (this.ALIGNLEFTRADIO)
  111.       onChange = class::ALIGNLEFTRADIO_ONCHANGE
  112.       height = 16
  113.       left = 11
  114.       top = 163
  115.       width = 47
  116.       text = "Left"
  117.       metric = 6
  118.       fontSize = 8
  119.       colornormal = "BtnText/BtnFace"
  120.       value = true
  121.       group = true
  122.       pageno = 0
  123.    endwith
  124.  
  125.  
  126.    this.ALIGNCENTERRADIO = new RADIOBUTTON(this)
  127.    with (this.ALIGNCENTERRADIO)
  128.       onChange = class::ALIGNCENTERRADIO_ONCHANGE
  129.       colorNormal = 'BtnText/BtnFace'
  130.       height = 19
  131.       left = 11
  132.       top = 182
  133.       width = 50
  134.       text = "Center"
  135.       metric = 6
  136.       fontSize = 8
  137.       value = false
  138.       group = false
  139.       pageno = 0
  140.    endwith
  141.  
  142.  
  143.    this.COLORFIELD = new ENTRYFIELD(this)
  144.    with (this.COLORFIELD)
  145.       height = 19
  146.       left = 120
  147.       top = 163
  148.       width = 64
  149.       metric = 6
  150.       fontSize = 8
  151.       value = "0x000000"
  152.       pageno = 0
  153.       borderStyle = 7
  154.    endwith
  155.  
  156.  
  157.    this.COLORBUTTON = new PUSHBUTTON(this)
  158.    with (this.COLORBUTTON)
  159.       onClick = class::COLORBUTTON_ONCLICK
  160.       height = 19
  161.       left = 188
  162.       top = 163
  163.       width = 25
  164.       text = ""
  165.       metric = 6
  166.       upBitmap = "RESOURCE #148"
  167.       fontSize = 8
  168.       group = true
  169.       pageno = 0
  170.    endwith
  171.  
  172.  
  173.    this.FONTCOMBO = new COMBOBOX(this)
  174.    with (this.FONTCOMBO)
  175.       onChange = class::FONTCOMBO_ONCHANGE
  176.       onOpen = class::FONTCOMBO_ONOPEN
  177.       height = 19
  178.       left = 271
  179.       top = 161
  180.       width = 83
  181.       metric = 6
  182.       fontSize = 8
  183.       dataSource = 'array {"Normal","Header 1","Header 2","Header 3","Header 4","Header 5"}'
  184.       pageno = 0
  185.       style = 1
  186.       dropDownHeight = 114
  187.    endwith
  188.  
  189.  
  190.    this.ATTRIBCOMBO = new COMBOBOX(this)
  191.    with (this.ATTRIBCOMBO)
  192.       onChange = class::ATTRIBCOMBO_ONCHANGE
  193.       onOpen = class::ATTRIBCOMBO_ONOPEN
  194.       height = 19
  195.       left = 271
  196.       top = 184
  197.       width = 83
  198.       metric = 6
  199.       fontSize = 8
  200.       dataSource = 'array {"Normal","Bold","Italic","Bold Italic","Underline","Bold Underline"}'
  201.       pageno = 0
  202.       style = 1
  203.       dropDownHeight = 114
  204.    endwith
  205.  
  206.  
  207.    this.TEXT3 = new TEXT(this)
  208.    with (this.TEXT3)
  209.       height = 13
  210.       left = 236
  211.       top =164
  212.       width = 27
  213.       metric = 6
  214.       colorNormal = "BtnText"
  215.       fontSize = 8
  216.       text = "Tag"
  217.       pageno = 0
  218.    endwith
  219.  
  220.  
  221.    this.TEXT4 = new TEXT(this)
  222.    with (this.TEXT4)
  223.       height = 19
  224.       left = 236
  225.       top = 186
  226.       width = 27
  227.       metric = 6
  228.       colorNormal = "BtnText"
  229.       fontSize = 8
  230.       text = "Style"
  231.       pageno = 0
  232.    endwith
  233.  
  234.    // {Linked Method} form.firstpagetitle.attribcombo.onOpen
  235.    function AttribCombo_onOpen
  236.       if this.value = 'Combo'
  237.          this.value = 'Normal'
  238.       endif
  239.       return
  240.  
  241.  
  242.    // {Linked Method} form.firstpagetitle.colorbutton.onClick
  243.    function COLORBUTTON_onClick
  244.       cColor = GetColor()
  245.       if len(trim(cColor)) > 0
  246.  
  247.         // set control value and redisplay the result
  248.         this.parent.colorfield.value = class::ColorToHex(cColor)
  249.  
  250.         class::UpdateDisplay(this.parent.display.text)
  251.         
  252.  
  253.       endif
  254.  
  255.       return
  256.  
  257.  
  258.    // {Linked Method} form.firstpagetitle.fontcombo.onOpen
  259.    function FONTCOMBO_onOpen
  260.       if this.value = 'Combo'
  261.          this.value = 'Normal'
  262.       endif
  263.       return
  264.  
  265.    
  266.    // Method: ColorToHex //////  converts RGB values to Hex color
  267.    ///////////////////////////////////  Param cColor RGB Color (225,225,044)
  268.  
  269.    function ColorToHex(cColor)
  270.       local cColor3,cColor2,cColor1
  271.  
  272.                                  // parse out RGB strings as Hex 
  273.                                  // Note that VdB 7 use BGR, not RGB,
  274.                                  // so first and last colors must be
  275.                                  // reversed when used in Browser.
  276.  
  277.       cColor1     = class::FixZero(itoh(val(substr(cColor,1,at(',',cColor)-1))))
  278.       cColor      = substr(cColor,at(',',cColor)+1) 
  279.  
  280.       cColor2     = class::FixZero(itoh(val(substr(cColor,1,at(',',cColor)-1))))
  281.       cColor      = substr(cColor,at(',',cColor)+1)
  282.  
  283.       cColor3     = class::FixZero(itoh(val(substr(cColor,1))))
  284.  
  285.  
  286.          //Note: Please note strange order of colors. Colors in VdB
  287.          //      are reversed to BGR instead of RGB and use 0x to indicate
  288.          //      hexidecimal values.
  289.       return '0x'+cColor3+cColor2+cColor1  
  290.  
  291.    // Method: FixZero = add "0" for single-char Hex (0) to create
  292.    //                   HEX pair (00) for color string.
  293.    function FixZero(cNum)
  294.       return iif(len(cNum) = 1,'0'+cNum,cNum)
  295.  
  296.  
  297.    // {Linked Method} form.firstpagetitle.fontcombo.onChange
  298.    function FONTCOMBO_onChange
  299.       class::UpdateDisplay(this.parent.display.text)
  300.       return
  301.  
  302.  
  303.    // Method:  UpdateDisplay ///////////////////////////////////////////
  304.    // Purpose: To Call BuildHTMLString for Web Wizard display controls
  305.    //          In response to changes in attribute settings
  306.    function UpdateDisplay(  cStr )
  307.                // call BuildHMTLString function for this particular
  308.                // control's text value
  309.     
  310.      if type('this.parent.display') = 'O'  // text object must be 
  311.                                                  // instantiated for display
  312.        
  313.         // replace text with updated HTML values according to
  314.         // control values in this container
  315.         this.parent.display.text = ;
  316.             class::BuildHTMLString( (cStr) )
  317.  
  318.      endif
  319.  
  320.      return true
  321.  
  322.  
  323.    
  324.  
  325.    // {Linked Method} form.firstpagetitle.aligncenterradio.onChange
  326.    function ALIGNCENTERRADIO_onChange
  327.       class::UpdateDisplay(this.parent.display.text)
  328.       return
  329.  
  330.    // {Linked Method} form.firstpagetitle.alignleftradio.onChange
  331.    function ALIGNLEFTRADIO_onChange
  332.       class::UpdateDisplay(this.parent.display.text)
  333.       return
  334.  
  335.    // {Linked Method} form.firstpagetitle.attribcombo.onChange
  336.    function ATTRIBCOMBO_onChange
  337.       class::UpdateDisplay(this.parent.display.text)
  338.       return
  339.  
  340.    /*  Method: BuildHTMString ////////////////////////////////////////
  341.       Purpose: Rebuilds attributes of test string to display selections
  342.                Made in GetHTML container text formatting controls
  343.       Params:  cStr     -  the string to format with HTML tags
  344.                oParent  -  the GetHTML container in which attributes are set
  345.                            for this particular string
  346.  
  347.       Note:    This method was "genericized" using the oParent object
  348.                reference so that it could be reused in the streaming
  349.                engine of this Web Wizard - AAK
  350.    */
  351.  
  352.    function BuildHTMLString(cStr)
  353.  
  354.       
  355.       /* before you build HTML tagged string, remove any tags
  356.          that may already exist
  357.  
  358.       */
  359.       
  360.       
  361.       // first, strip off endtags (if any)
  362.       if at('</',cStr) > 0
  363.          
  364.          cStr = substr(cStr,1,at('</',cStr)-1)
  365.  
  366.       endif
  367.      
  368.         // Now, get rid of starting tags
  369.       do while at('>',cStr) > 0
  370.  
  371.          cStr = substr(cStr,at('>',cStr)+1)
  372.  
  373.       enddo
  374.  
  375.       
  376.       // Next, build string from "inside-out"
  377.  
  378.       // Attributes first
  379.  
  380.      
  381.  
  382.       if at('Underline',this.parent.AttribCombo.value) > 0
  383.          cStr = '<U>'+cStr+'</U>'
  384.       endif
  385.       if at('Bold',this.parent.AttribCombo.value) > 0
  386.          cStr = '<B>'+cStr+'</B>'
  387.       endif
  388.       if at('Italic',this.parent.AttribCombo.value) > 0
  389.          cStr = '<I>'+cStr+'</I>'
  390.       endif   
  391.  
  392.       
  393.  
  394.  
  395.       // Then, color and alignment
  396.                                      //+o
  397.       cStr = '<Font color="0x'+this.parent.ColorField.value+'">'+cStr+'</Font>'
  398.   
  399.      
  400.  
  401.       // Then, text style
  402.  
  403.       if at('Header',this.parent.FontCombo.value) > 0
  404.          cStr = '<H'+ substr(this.parent.FontCombo.value,8,1)+;
  405.                 ' align='+iif(this.parent.AlignLeftRadio.value,'left','center')+;
  406.                 '>'+cStr+'</H'+substr(this.parent.FontCombo.value,8,1)+'>'
  407.  
  408.       else
  409.          // Paragraph,alignment:
  410.          cStr = '<P '+'align='+iif(this.parent.AlignLeftRadio.value,;
  411.              "left", "center")+'>'+cStr+'</P>'
  412.       endif
  413.  
  414.       return cStr
  415.  
  416. endclass
  417.