Module cSigCJCheckBox.pkg

     1//==============================================================================
     2// Project      : SigCj - VDF Classes for Codejock
     3// File         : cSigCJCheckBox.pkg
     4// Description  : VDF Class for Codejock control
     5//
     6// Revision     : $Rev: 675 $
     7//                $Date: 2011-02-23 10:51:39 -0500 (Wed, 23 Feb 2011) $
     8//                $Author: martin $ Martin Pincott
     9// 
    10// Requirements : Visual DataFlex 12.1+
    11//                Codejock SuitePro - Version 12.0.0+
    12//
    13// Copyright    : (c) 2008 VDF SIG UK
    14//                Visual DataFlex Special Interest Group UK.
    15//                http://www.vdfsig.co.uk/
    16//                dev@vdfsig.co.uk
    17//
    18//                This file is part of SigCj.
    19//
    20//                SigCj is free software: you can redistribute it and/or modify
    21//                it under the terms of the GNU Lesser General Public License 
    22//                as published by the Free Software Foundation, either version 
    23//                2.1 of the License, or (at your option) any later version.
    24//
    25//                SigCj is distributed in the hope that it will be useful, but 
    26//                WITHOUT ANY WARRANTY; without even the implied warranty of
    27//                MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    28//                GNU Lesser General Public License for more details.
    29//
    30//                If you have the complete SigCj workspace then a copy of the  
    31//                GNU Lesser General Public License is in the Docs folder. If  
    32//                not, see <http://www.gnu.org/licenses/>.
    33//    
    34//==============================================================================
    35
    36Use SigCjW_CheckBox.pkg
    37Use cSigCJMethods_Mixin.pkg
    38
    39{DocStart = Package}
    40//=============================================================================    
    41//Check Box Value
    42//
    43//We have to control the check box value if we want a tri-state box. When 
    44//clicked the control behaves as a two state box.
    45//
    46//=============================================================================    
    47{DocEnd}
    48
    49Class cSigCJCheckBox_Mixin is a Mixin
    50
    51    Procedure Initialise_cSigCJCheckBox_Mixin
    52
    53        { DesignTime=False }
    54        Property Integer Private_peAppearance OLExtpAppearanceStandard
    55
    56        { DesignTime=False }
    57        Property Integer Private_piBackColor clBtnFace
    58
    59        { DesignTime=False }
    60        Property String  Private_psCaption ""
    61
    62        { DesignTime=False }
    63        Property Boolean Private_pbDrawFocusRect True
    64
    65        { DesignTime=False }
    66        Property Boolean Private_pbEnabled True
    67
    68        { DesignTime=False }
    69        Property Boolean Private_pbEnableMarkup False
    70
    71        { DesignTime=False }
    72        Property Integer Private_piForeColor clBlack
    73
    74        { DesignTime=False }
    75        Property Boolean Private_pbMultiLine True
    76
    77        { DesignTime=False }
    78        Property Boolean Private_pbRightToLeft False
    79
    80        { DesignTime=False }
    81        Property Integer Private_peTextAlignment OLExtpAlignLeft
    82
    83        { DesignTime=False }
    84        Property Boolean Private_pbUseVisualStyle True
    85
    86        //Property Private_p Font                         Gets/Sets the font that will be used to display the text for the control.
    87        //Property Private_p hWnd                         Gets the window handle that the control is bound to.
    88        //Property Private_p OLEDropMode                  Returns or sets how a target component handles drop operations.
    89        //Property Private_p Transparent                  Determines if the background of a TabControlPage is visible in WinXP mode.
    90
    91        { DesignTime=False }
    92        Property Boolean Private_pbValueChanging False  //controls reentrency in OnComClivk
    93
    94        { DesignTime=False }
    95        Property Integer Private_piValue 0              //Value of control
    96
    97        //Properties to hold True / False values. Default to standard numeric values
    98        { Category="CodeJock" InitialValue="0" }
    99        Property String psFalse 0
   100
   101        {  Category="CodeJock" InitialValue="1" }
   102        Property String psTrue 1
   103
   104        { Category="CodeJock" InitialValue="2" }
   105        Property String psGrayed 2
   106
   107        { Category="CodeJock" InitialValue=True }
   108        Property Boolean pbTriState True
   109
   110    End_Procedure
   111    
   112    Procedure OnCreate
   113        Forward Send OnCreate
   114
   115        Set peAppearance        to (Private_peAppearance(Self))
   116        Set piBackColor         to (Private_piBackColor(Self))
   117        Set pbDrawFocusRect     to (Private_pbDrawFocusRect(Self))
   118        Set pbEnabled           to (Private_pbEnabled(Self))
   119        Set pbEnableMarkup      to (Private_pbEnableMarkup(Self))
   120        Set piForeColor         to (Private_piForeColor(Self))
   121        Set pbMultiLine         to (Private_pbMultiLine(Self))
   122        Set pbRightToLeft       to (Private_pbRightToLeft(Self))
   123        Set peTextAlignment     to (Private_peTextAlignment(Self))
   124        Set pbUseVisualStyle    to (Private_pbUseVisualStyle(Self))
   125
   126        //This needs to be done after Multiline, so do it at the end incase 
   127        //some of the other properies effect it as well.
   128        Set psCaption           to (Private_psCaption(Self))
   129    End_Procedure
   130
   131    //-------------------------------------------------------------------------
   132
   133    #IF (SigCj_Codejock_Version < 150001) 
   134        { MethodType=Property Category="CodeJock" InitialValue=OLExtpAppearanceStandard }
   135        { EnumList="OLExtpAppearanceStandard, OLExtpAppearanceFlat, OLExtpAppearanceUltraFlat, OLExtpAppearanceOffice2000, OLExtpAppearanceOffice2000, OLExtpAppearanceOffice2003, OLExtpAppearanceOffice2007" }
   136    #ELSE    
   137        { MethodType=Property Category="CodeJock" InitialValue=OLExtpAppearanceStandard }
   138        { EnumList="OLExtpAppearanceStandard, OLExtpAppearanceFlat, OLExtpAppearanceUltraFlat, OLExtpAppearanceOffice2000, OLExtpAppearanceOffice2000, OLExtpAppearanceOffice2003, OLExtpAppearanceResource" }
   139    #ENDIF 
   140    Procedure Set peAppearance Integer eAppearance
   141        Set SigCJProperty Set_Private_peAppearance Set_ComAppearance to eAppearance
   142    End_Procedure
   143    
   144    Function peAppearance Returns Integer
   145        Function_Return (SigCJProperty(Self, Get_Private_peAppearance, Get_ComAppearance ))
   146    End_Function
   147
   148    //-------------------------------------------------------------------------
   149
   150    { MethodType=Property Category="CodeJock" PropertyType=Color InitialValue=clBtnFace }
   151    Procedure Set piBackColor Integer iColor
   152        Set SigCJProperty Set_Private_piBackColor Set_ComBackColor to iColor
   153    End_Procedure
   154    
   155    Function piBackColor Returns Integer
   156        Function_Return (SigCJProperty(Self, Get_Private_piBackColor, Get_ComBackColor ))
   157    End_Function
   158
   159    //-------------------------------------------------------------------------
   160
   161    { MethodType=Property Category="CodeJock" InitialValue="" }
   162    Procedure Set psCaption String sCaption
   163        Set SigCJProperty Set_Private_psCaption Set_ComCaption to sCaption
   164    End_Procedure
   165    
   166    Function psCaption Returns String
   167        Function_Return (SigCJProperty(Self, Get_Private_psCaption, Get_ComCaption ))
   168    End_Function
   169
   170    //-------------------------------------------------------------------------
   171
   172    { MethodType=Property Category="CodeJock" InitialValue=True }
   173    Procedure Set pbDrawFocusRect Boolean bState
   174        Set SigCJProperty Set_Private_pbDrawFocusRect Set_ComDrawFocusRect to bState
   175    End_Procedure
   176    
   177    Function pbDrawFocusRect Returns Boolean
   178        Function_Return (SigCJProperty(Self, Get_Private_pbDrawFocusRect, Get_ComDrawFocusRect ))
   179    End_Function
   180
   181    //-------------------------------------------------------------------------
   182
   183    { MethodType=Property Category="CodeJock" InitialValue=True }
   184    Procedure Set pbEnabled Boolean bState
   185        Set SigCJProperty Set_Private_pbEnabled Set_ComEnabled to bState
   186    End_Procedure
   187    
   188    Function pbEnabled Returns Boolean
   189        Function_Return (SigCJProperty(Self, Get_Private_pbEnabled, Get_ComEnabled ))
   190    End_Function
   191
   192    //-------------------------------------------------------------------------
   193
   194    { MethodType=Property Category="CodeJock" InitialValue=False }
   195    Procedure Set pbEnableMarkup Boolean bState
   196        Set SigCJProperty Set_Private_pbEnableMarkup Set_ComEnableMarkup to bState
   197    End_Procedure
   198    
   199    Function pbEnableMarkup Returns Boolean
   200        Function_Return (SigCJProperty(Self, Get_Private_pbEnableMarkup, Get_ComEnableMarkup ))
   201    End_Function
   202
   203    //-------------------------------------------------------------------------
   204
   205    { MethodType=Property Category="CodeJock" PropertyType=Color InitialValue=clBlack }
   206    Procedure Set piForeColor Integer iColor
   207        Set SigCJProperty Set_Private_piForeColor Set_ComForeColor to iColor
   208    End_Procedure
   209    
   210    Function piForeColor Returns Integer
   211        Function_Return (SigCJProperty(Self, Get_Private_piForeColor, Get_ComForeColor ))
   212    End_Function
   213
   214    //-------------------------------------------------------------------------
   215
   216    { MethodType=Property Category="CodeJock" InitialValue=False }
   217    Procedure Set pbMultiLine Boolean bState
   218        Set SigCJProperty Set_Private_pbMultiLine Set_ComMultiLine to bState
   219    End_Procedure
   220    
   221    Function pbMultiLine Returns Boolean
   222        Function_Return (SigCJProperty(Self, Get_Private_pbMultiLine, Get_ComMultiLine ))
   223    End_Function
   224
   225    //-------------------------------------------------------------------------
   226
   227    { MethodType=Property Category="CodeJock" InitialValue=False }
   228    Procedure Set pbRightToLeft Boolean bState
   229        Set SigCJProperty Set_Private_pbRightToLeft Set_ComRightToLeft to bState
   230    End_Procedure
   231    
   232    Function pbRightToLeft Returns Boolean
   233        Function_Return (SigCJProperty(Self, Get_Private_pbRightToLeft, Get_ComRightToLeft ))
   234    End_Function
   235
   236    //-------------------------------------------------------------------------
   237
   238    { MethodType=Property Category="CodeJock" InitialValue=OLExtpAlignLeft }
   239    { EnumList="OLExtpAlignLeft, OLExtpAlignRight, OLExtpAlignCenter, OLExtpAlignMiddle, OLExtpAlignTop, OLExtpAlignBottom" }
   240    Procedure Set peTextAlignment Integer eAlign
   241        Set SigCJProperty Set_Private_peTextAlignment Set_ComTextAlignment to eAlign
   242    End_Procedure
   243    
   244    Function peTextAlignment Returns Integer
   245        Function_Return (SigCJProperty(Self, Get_Private_peTextAlignment, Get_ComTextAlignment ))
   246    End_Function
   247
   248    //-------------------------------------------------------------------------
   249
   250    { MethodType=Property Category="CodeJock" InitialValue=True }
   251    Procedure Set pbUseVisualStyle Boolean bState
   252        Set SigCJProperty Set_Private_pbUseVisualStyle Set_ComUseVisualStyle to bState
   253    End_Procedure
   254    
   255    Function pbUseVisualStyle Returns Boolean
   256        Function_Return (SigCJProperty(Self, Get_Private_pbUseVisualStyle, Get_ComUseVisualStyle ))
   257    End_Function
   258
   259    //-------------------------------------------------------------------------
   260
   261    { MethodType=Property DesignTime=False }
   262    Function psValue Returns String
   263        Integer iValue
   264        
   265        Get Private_piValue to iValue
   266
   267        //Lots of exit points... I don't like this, but they are all together        
   268        If (iValue = 0) Function_Return (psFalse(Self))
   269        If (iValue = 1) Function_Return (psTrue(Self))
   270        If (iValue = 2) Function_Return (psGrayed(Self))
   271        
   272        //Catch - should never happen
   273        Function_Return "*Error*"
   274    End_Function
   275
   276    //-------------------------------------------------------------------------
   277    // Dataflex interface properties
   278    { MethodType=Property }
   279    Procedure Set Label String sValue
   280        Set psCaption to sValue
   281    End_Procedure
   282    
   283    Function Label Returns String
   284        Function_Return (psCaption(Self))
   285    End_Function                       
   286
   287    Function Checked_State Returns Integer
   288        Function_Return (Private_piValue(Self))
   289    End_Function  
   290
   291    //-------------------------------------------------------------------------
   292    
   293    Procedure OnComClick
   294        Integer iValue
   295        
   296        If (not(Private_pbValueChanging(Self))) Begin
   297            Set Private_pbValueChanging to True
   298            
   299            Get Private_piValue to iValue
   300            
   301            If (pbTriState(Self)) Begin
   302                If (iValue = 2) Move 0 to iValue
   303                Else Increment iValue
   304            End
   305            Else Move (not(iValue)) to iValue
   306            
   307            Set Private_piValue  to iValue
   308            Set ComValue to iValue
   309
   310            Set Private_pbValueChanging to False
   311            
   312            Send OnChange
   313        End
   314    End_Procedure
   315
   316    //Hook - Fired when the value changes
   317    Procedure OnChange
   318    End_Procedure
   319
   320End_Class
   321    
   322//==============================================================================
   323 
   324 
   325{ OverrideProperty=Label_Col_Offset          DesignTime=False }
   326{ OverrideProperty=Label_Justification_Mode  DesignTime=False }
   327{ OverrideProperty=Label_Row_Offset          DesignTime=False }
   328{ OverrideProperty=piMinSize                 DesignTime=False }
   329{ OverrideProperty=Border_Style              DesignTime=False }
   330{ OverrideProperty=Visible_State             DesignTime=False }
   331{ OverrideProperty=Attach_Parent_State       DesignTime=False }
   332{ OverrideProperty=Block_Mouse_State         DesignTime=False }
   333{ OverrideProperty=Client_Area_State         DesignTime=False }
   334{ OverrideProperty=Delegation_Mode           DesignTime=False }
   335{ OverrideProperty=Focus_Mode                DesignTime=False }
   336{ OverrideProperty=pbBindValue               DesignTime=False }
   337{ OverrideProperty=peAutoCreate              DesignTime=False }
   338{ OverrideProperty=peNeighborhood            DesignTime=False }
   339{ OverrideProperty=Popup_State               DesignTime=False }
   340{ OverrideProperty=Ring_State                DesignTime=False }
   341{ OverrideProperty=Scope_State               DesignTime=False }
   342{ OverrideProperty=Search_Case               DesignTime=False }
   343{ OverrideProperty=Skip_State                DesignTime=False }
   344{ OverrideProperty=Help_Id                   DesignTime=False }
   345{ OverrideProperty=Help_Keyword              DesignTime=False }
   346{ OverrideProperty=psHtmlHelpTopic           DesignTime=False }
   347{ OverrideProperty=Status_Help               DesignTime=False }
   348{ OverrideProperty=Use_Parent_Status_Help    DesignTime=False }
   349{ OverrideProperty=psLicenseKey              DesignTime=False }
   350{ OverrideProperty=psProgID                  DesignTime=False }
   351{ OverrideProperty=Color                     DesignTime=False }
   352{ OverrideProperty=TextColor                 DesignTime=False }
   353{ OverrideProperty=Enabled_State             DesignTime=False }
   354Class cSigCJCheckBox is a cSigCjComCheckBox
   355    Import_Class_Protocol cSigCJMethods_Mixin
   356    Import_Class_Protocol cSigCJCheckBox_Mixin
   357    
   358    Procedure Construct_Object
   359        Forward Send Construct_Object
   360
   361        Send Initialise_cSigCJCheckBox_Mixin        
   362    End_Procedure  // Construct_Object  
   363    
   364End_Class
   365
   366//==============================================================================
   367
   368{ OverrideProperty=Label_Col_Offset          DesignTime=False }
   369{ OverrideProperty=Label_Justification_Mode  DesignTime=False }
   370{ OverrideProperty=Label_Row_Offset          DesignTime=False }
   371{ OverrideProperty=piMinSize                 DesignTime=False }
   372{ OverrideProperty=Border_Style              DesignTime=False }
   373{ OverrideProperty=Visible_State             DesignTime=False }
   374{ OverrideProperty=Attach_Parent_State       DesignTime=False }
   375{ OverrideProperty=Block_Mouse_State         DesignTime=False }
   376{ OverrideProperty=Client_Area_State         DesignTime=False }
   377{ OverrideProperty=Delegation_Mode           DesignTime=False }
   378{ OverrideProperty=Focus_Mode                DesignTime=False }
   379{ OverrideProperty=pbBindValue               DesignTime=False }
   380{ OverrideProperty=peAutoCreate              DesignTime=False }
   381{ OverrideProperty=peNeighborhood            DesignTime=False }
   382{ OverrideProperty=Popup_State               DesignTime=False }
   383{ OverrideProperty=Ring_State                DesignTime=False }
   384{ OverrideProperty=Scope_State               DesignTime=False }
   385{ OverrideProperty=Search_Case               DesignTime=False }
   386{ OverrideProperty=Skip_State                DesignTime=False }
   387{ OverrideProperty=Help_Id                   DesignTime=False }
   388{ OverrideProperty=Help_Keyword              DesignTime=False }
   389{ OverrideProperty=psHtmlHelpTopic           DesignTime=False }
   390{ OverrideProperty=Status_Help               DesignTime=False }
   391{ OverrideProperty=Use_Parent_Status_Help    DesignTime=False }
   392{ OverrideProperty=psLicenseKey              DesignTime=False }
   393{ OverrideProperty=psProgID                  DesignTime=False }
   394{ OverrideProperty=Color                     DesignTime=False }
   395{ OverrideProperty=TextColor                 DesignTime=False }
   396{ OverrideProperty=Enabled_State             DesignTime=False }
   397Class cSigCJdbCheckBox is a cSigCjComDbCheckBox
   398    Import_Class_Protocol cSigCJMethods_Mixin
   399    Import_Class_Protocol cSigCJCheckBox_Mixin
   400
   401    Procedure Construct_Object
   402        Forward Send Construct_Object
   403
   404        Send Initialise_cSigCJCheckBox_Mixin        
   405    End_Procedure  // Construct_Object
   406
   407    //=========================================================================
   408
   409    Procedure End_Construct_Object
   410        Handle  hoMain_DD hoDD
   411        Integer iValidation_Type iFile iField
   412        String  sTrue sFalse //sValue 
   413
   414        Forward Send End_Construct_Object
   415
   416        Get Data_File  to iFile     //this gets the Entry_Items' file number
   417        Get Data_Field to iField    //this gets the Entry_Items' field number
   418        
   419        //Get the actual DD that supplies data for the Entry_Item file.field
   420        Get Main_DD                     to hoMain_DD //this gives us the view DD
   421        Get Data_Set of hoMain_DD iFile to hoDD      //this gives us the actual DD         
   422
   423        //Now we can get the fields' validation type
   424        Get Field_Validation_Type of (Field_Attributes(hoDD)) iField to iValidation_Type
   425
   426        If (iValidation_Type = FA_VALIDATION_TYPE_CHECKBOX) Begin
   427            //Defined as a check box so can only be TRUE / FALSE - not grayed
   428            Get Field_CheckBox_Value of hoDD iField True  to sTrue
   429            Get Field_CheckBox_Value of hoDD iField False to sFalse
   430
   431            Set pbTriState to False
   432            Set psTrue     to sTrue  
   433            Set psFalse    to sFalse
   434            Set psGrayed   to sFalse  //Just in case
   435        End
   436    End_Procedure
   437    
   438    //=========================================================================
   439
   440    Function ControlValue Returns String
   441        Function_Return (psValue(Self)) 
   442    End_Function
   443
   444    Procedure Set ControlValue String sValue
   445        Integer iComValue 
   446
   447        If (pbTriState(Self)) Begin
   448            Move OLExtpGrayed to iComValue            
   449            If (sValue = (psTrue(Self)))  Move OLExtpChecked   to iComValue
   450            If (sValue = (psFalse(Self))) Move OLExtpUnchecked to iComValue
   451        End
   452        Else Begin
   453            Move OLExtpUnchecked to iComValue            
   454            If (sValue = (psTrue(Self)))  Move OLExtpChecked   to iComValue
   455        End
   456
   457        //Stop the standard click event firing
   458        Set Private_pbValueChanging to True
   459            Set ComValue to iComValue
   460            Set Private_piValue to iComValue
   461            Send OnChange
   462        Set Private_pbValueChanging to False
   463    End_Procedure
   464
   465    //=========================================================================
   466
   467End_Class
   468
   469//==============================================================================
   470//End of package - cSigCJCheckBox.pkg
   471//==============================================================================
   472