Module cSigCJMessageBar.pkg

     1//==============================================================================
     2// Project      : SigCj - VDF Classes for Codejock
     3// File         : cSigCJMessageBar.pkg
     4// Description  : VDF Class for Codejock control
     5//
     6// Revision     : $Rev: 343 $
     7//                $Date: 2010-02-26 22:57:12 +0000 (Fri, 26 Feb 2010) $
     8//                $Author: martin $ Martin Pincott and Pieter van Dieren
     9// 
    10// Requirements : Visual DataFlex 12.1+
    11//                Codejock SuitePro - Version 12.0.0+
    12//
    13// Copyright    : (c) 2010 VDF SIG UK
    14//                Visual DataFlex Special Interest Group UK.
    15//                http://www.vdfsig.co.uk/
    16//
    17//                This file is part of SigCj.
    18//
    19//                SigCj is free software: you can redistribute it and/or modify
    20//                it under the terms of the GNU Lesser General Public License 
    21//                as published by the Free Software Foundation, either version 
    22//                2.1 of the License, or (at your option) any later version.
    23//
    24//                SigCj is distributed in the hope that it will be useful, but 
    25//                WITHOUT ANY WARRANTY; without even the implied warranty of
    26//                MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    27//                GNU Lesser General Public License for more details.
    28//
    29//                If you have the complete SigCj workspace then a copy of the  
    30//                GNU Lesser General Public License is in the Docs folder. If  
    31//                not, see <http://www.gnu.org/licenses/>.
    32//    
    33//==============================================================================
    34// Contributions
    35// =============
    36//
    37// When       Who                 What
    38// ========== =================== =====================================================
    39// 2010-02-26 Pieter van Dieren   Initial Idea and code sample 
    40//
    41//==============================================================================
    42
    43Use SigCjW_Controls.pkg
    44Use cCJCommandBars.pkg
    45Use cSigCJMethods_Mixin.pkg
    46Use cHexLib.Pkg
    47
    48Class cSigCJMessageBar is a cCJMessageBar
    49    Import_Class_Protocol cSigCJMethods_Mixin    
    50    
    51    Procedure Construct_Object
    52        Forward Send Construct_Object
    53
    54        { DesignTime=False Visibility=Private }
    55        Property Boolean Private_pbVisible True 
    56    
    57        { DesignTime=False Visibility=Private }
    58        Property String  Private_psMessage 
    59
    60        { DesignTime=False Visibility=Private }
    61        Property Boolean Private_pbCloseButton True
    62        
    63        { MethodType=Property Category="CodeJock" PropertyType=Color }
    64        { EnumList="clAqua, clBlack, clBlue, clDkGray, clFuchsia, clGray, clGreen, clLime, clLtGray" }
    65        { EnumList+="clMaroon, clNavy, clOlive, clPurple, clRed, clSilver, clTeal, clWhite, clYellow" }
    66        Property Integer piTextColor clBlack
    67        
    68        { MethodType=Property Category="CodeJock" }
    69        Property String psCloseButtonTooltip "Close"
    70
    71        Object oHex is a cHexLib
    72        End_Object
    73    End_Procedure
    74    
    75    //-------------------------------------------------------------------------
    76
    77    { MethodType=Property Category="CodeJock" InitialValue=False }
    78    Procedure Set pbVisible Boolean bState
    79        Set SigCJProperty Set_Private_pbVisible Set_ComVisible to bState
    80    End_Procedure
    81    
    82    Function pbVisible Returns Boolean
    83        Function_Return (SigCJProperty(Self, Get_Private_pbVisible, Get_ComVisible ))
    84    End_Function
    85
    86    //-------------------------------------------------------------------------
    87
    88    { MethodType=Property Category="CodeJock" InitialValue=True }
    89    Procedure Set pbCloseButton Boolean bState
    90        Set Private_pbCloseButton to bState
    91        If (bState) Send ComAddCloseButton (psCloseButtonTooltip(Self)) 
    92    End_Procedure
    93    
    94    Function pbCloseButton Returns Boolean
    95        Function_Return (Private_pbCloseButton(Self))
    96    End_Function
    97
    98    //-------------------------------------------------------------------------
    99    
   100    { MethodType=Event }
   101    Procedure Add_Close_Button String llToolTip
   102        Send ComAddCloseButton llToolTip
   103    End_Procedure
   104
   105    { MethodType=Event }
   106    Procedure Add_Button Integer llId String llCaption String llToolTip
   107        Send ComAddButton llId llCaption llToolTip
   108    End_Procedure
   109
   110    { MethodType=Event }
   111    Procedure Remove_Buttons 
   112        Send ComRemoveButtons
   113    End_Procedure
   114
   115    // Convert illegal characters to XAML entities
   116    { Visibility=Private }
   117    Function EncodePlaintext String sMessage Returns String
   118        Move (Replaces("&",sMessage,"&"))     to sMessage
   119        Move (Replaces("<",sMessage,"<"))      to sMessage
   120        Move (Replaces(">",sMessage,">"))      to sMessage
   121        Move (Replaces("'",sMessage,"'"))    to sMessage
   122        Move (Replaces('"',sMessage,"""))    to sMessage
   123        Move (Replaces("\n",sMessage,"
"))   to sMessage
   124        Function_Return sMessage
   125    End_Function // EncodePlaintext
   126   
   127//    // Convert decimal to Hex
   128//    { Visibility=Private }
   129//    Function DecToHex Integer iDec Returns String
   130//        String sHex sHexchars
   131//        Move "0123456789ABCDEF" to sHexchars
   132//        Move "" to sHex
   133//        Repeat
   134//            Insert (Mid(sHexchars,1,((iDec iand $0f) + 1))) In sHex At 1
   135//            Move (iDec / $10) to iDec
   136//        Until (iDec = 0)
   137//        Function_Return sHex
   138//    End_Function
   139//   
   140//    // RgbToHex
   141//    // Convert the RGB color to a hex color
   142//    { Visibility=Private }
   143//    Function RgbToHex Integer iColor Returns String
   144//        String sRed sGreen sBlue
   145//        
   146//        Get DecToHex of oHex (R_From_RGB(iColor)) to sRed
   147//        Get DecToHex of oHex (G_From_RGB(iColor)) to sGreen
   148//        Get DecToHex of oHex (B_From_RGB(iColor)) to sBlue
   149//        
   150//        Move (Right(("00" + sRed),2))   to sRed
   151//        Move (Right(("00" + sGreen),2)) to sGreen
   152//        Move (Right(("00" + sBlue),2))  to sBlue
   153//        
   154//        Function_Return ("#" + sRed + sGreen + sBlue)
   155//    End_Function
   156   
   157    { Visibility=Private }
   158    Procedure DoShowMessageBar String sMessage String sMessageTitle
   159        String sXml sHexColor
   160        
   161        If (IsComObjectCreated(Self)) Begin
   162            Get HexColor of oHex (piTextColor(Self)) to sHexColor
   163            
   164            Move ("" + ;
   165               " " + EncodePlaintext(Self,sMessageTitle) + "" + ;
   166               " " + EncodePlaintext(Self,sMessage) + "" + ;
   167               "") to sMessage
   168            
   169            Set ComMessage to sMessage
   170        End
   171    End_Procedure
   172   
   173End_Class
   174
   175