Module cSigCJPushButton.pkg

     1//==============================================================================
     2// Project      : SigCj - VDF Classes for Codejock
     3// File         : cSigCJPushButton.pkg
     4// Description  : VDF Class for Codejock control
     5//
     6// Revision     : $Rev: 692 $
     7//                $Date: 2011-05-04 10:38:15 -0400 (Wed, 04 May 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// Contributions
    36// =============
    37//
    38// When       Who             What
    39// ========== ============    ==================================================
    40// 2009-02-28 Tom Murphy      Default size same as VDF button, Hot tracking, 
    41//                            Pointer_Only and code for keyboard & mouse support.
    42// 2010-08-13 Katrien Naert   Added Tooltip support
    43// 2010-11-16 Nils G. Svedmyr Upadte Tooltip support to DAC Standard
    44//
    45//==============================================================================
    46
    47Use SigCjW_Controls.pkg
    48Use cSigCJMethods_Mixin.pkg
    49Use cSigCJGlobalSettings.pkg
    50Use StdFont.pkg
    51Use cSigCJContextMenu.pkg
    52
    53{ OverrideProperty=Label_Col_Offset         DesignTime=False }
    54{ OverrideProperty=Label_Justification_Mode DesignTime=False }
    55{ OverrideProperty=Label_Row_Offset         DesignTime=False }
    56{ OverrideProperty=piMinSize                DesignTime=False }
    57{ OverrideProperty=Border_Style             DesignTime=False }
    58{ OverrideProperty=Visible_State            DesignTime=False }
    59{ OverrideProperty=Attach_Parent_State      DesignTime=False }
    60{ OverrideProperty=Block_Mouse_State        DesignTime=False }
    61{ OverrideProperty=Client_Area_State        DesignTime=False }
    62{ OverrideProperty=Delegation_Mode          DesignTime=False }
    63{ OverrideProperty=Focus_Mode               DesignTime=False }
    64{ OverrideProperty=pbBindValue              DesignTime=False }
    65{ OverrideProperty=peAutoCreate             DesignTime=False }
    66{ OverrideProperty=peNeighborhood           DesignTime=False }
    67{ OverrideProperty=Popup_State              DesignTime=False }
    68{ OverrideProperty=Ring_State               DesignTime=False }
    69{ OverrideProperty=Scope_State              DesignTime=False }
    70{ OverrideProperty=Search_Case              DesignTime=False }
    71{ OverrideProperty=Skip_State               DesignTime=False }
    72{ OverrideProperty=Help_Id                  DesignTime=False }
    73{ OverrideProperty=Help_Keyword             DesignTime=False }
    74{ OverrideProperty=psHtmlHelpTopic          DesignTime=False }
    75{ OverrideProperty=Status_Help              DesignTime=False }
    76{ OverrideProperty=Use_Parent_Status_Help   DesignTime=False }
    77{ OverrideProperty=psLicenseKey             DesignTime=False }
    78{ OverrideProperty=psProgID                 DesignTime=False }
    79{ OverrideProperty=Color                    DesignTime=False }
    80{ OverrideProperty=TextColor                DesignTime=False }
    81//{ OverrideProperty=Enabled_State            DesignTime=False }
    82{ OverrideProperty=Size                     InitialValue=14,50 }
    83{ DesignerClass=cDTButton }
    84Class cSigCJPushButton is a cSigCjComPushButton
    85    Import_Class_Protocol cSigCJMethods_Mixin
    86
    87    //-------------------------------------------------------------------------
    88
    89    Procedure Construct_Object
    90        Forward Send Construct_Object
    91
    92        //The default COM size is 100 100, make it same as DAW button
    93        Set Size to 14 50
    94        
    95        { DesignTime=False }
    96        Property Integer Private_peAppearance OLExtpAppearanceStandard
    97
    98        { DesignTime=False }
    99        Property Integer Private_piBackColor clBtnFace
   100
   101        { DesignTime=False }
   102        Property Integer Private_piBorderGap 4
   103
   104        { DesignTime=False }
   105        Property String  Private_psCaption ""
   106
   107        { DesignTime=False }
   108        Property Boolean Private_pbChecked False
   109
   110        { DesignTime=False }
   111        Property Boolean Private_pbDefault False
   112
   113        { DesignTime=False }
   114        Property Boolean Private_pbDrawFocusRect True
   115
   116        { DesignTime=False }
   117        Property Boolean Private_pbEnabled True
   118
   119        { DesignTime=False }
   120        Property Boolean Private_pbEnableMarkup False
   121
   122        { DesignTime=False }
   123        Property Boolean Private_pbFlatStyle False
   124
   125        { DesignTime=False }
   126        Property Integer Private_piForeColor clWindowText
   127
   128        { DesignTime=False }
   129        Property String  Private_psImage ""
   130
   131        { DesignTime=False }
   132        Property Integer Private_peImageAlignment OLExtpAlignCenter
   133
   134        { DesignTime=False }
   135        Property Integer Private_piImageGap 3
   136
   137        { DesignTime=False }
   138        Property Boolean Private_pbMultiLine True
   139
   140        { DesignTime=False }
   141        Property Boolean Private_pbRightToLeft False
   142
   143        { DesignTime=False }
   144        Property Integer Private_peStyle OLExtpButtonNormal
   145
   146        { DesignTime=False }
   147        Property Integer Private_peTextAlignment OLExtpAlignCenter
   148
   149        { DesignTime=False }
   150        Property Integer Private_peTextImageRelation OLExtpImageBeforeText
   151
   152        { DesignTime=False }
   153        Property Boolean Private_pbUseVisualStyle True
   154
   155        { DesignTime=False }
   156        Property Boolean Private_pbValue
   157
   158        //Property Private_pihWnd                         Gets the window handle that the control is bound to.
   159        //Property Private_p OLEDropMode                  Returns or sets how a target component handles drop operations.
   160        //Property Private_p Picture                      Gets or sets a graphic to be displayed in a push button.
   161        //Property Private_p Transparent                  Determines if the background of a TabControlPage is visible in WinXP mode.
   162
   163        { DesignTime=False }
   164        Property boolean Private_pbBold False
   165
   166        { DesignTime=False }
   167        Property Boolean Private_pbItalic False
   168
   169        { DesignTime=False }
   170        Property Boolean Private_pbStrikethrough False
   171
   172        { DesignTime=False }
   173        Property Boolean Private_pbUnderline False
   174
   175        { DesignTime=False }
   176        Property String Private_psFontName "MS Sans Serif"
   177
   178        { DesignTime=False }
   179        Property Number Private_pnFontSize 8.25
   180
   181        { DesignTime=False }
   182        Property Handle Private_hoFont  (Create(Self, U_cComStdFont)) 
   183
   184        { DesignTime=False }
   185        Property String Private_psTooltip ""
   186        Property Handle phoToolTipController    ghoToolTipController 
   187
   188
   189        //---------------------------------------------------------------------
   190        
   191        Property Handle phoDropDownMenu
   192        { DesignTime=False }
   193        Property Boolean Private_pbInDropDown False
   194        
   195        //---------------------------------------------------------------------
   196        
   197        //pbPointer_Only - Prevents the button from taking the focus
   198        { Category=CodeJock }
   199        Property Boolean pbPointer_Only     False
   200
   201        //phoReturn_Focus - Store the invoking object so focus can be returned if pointer only
   202        { Category=CodeJock }
   203        Property Handle  phoReturn_Focus    0
   204
   205        { Category=CodeJock }
   206        Property Boolean pbEnableHotTrack   True
   207
   208        { Category=CodeJock PropertyType=Color InitialValue=clBlue }
   209        { EnumList= "cl3DDkShadow, cl3DLight, clActiveBorder, clActiveCaption, clAppWorkSpace, clBackground"    }
   210        { EnumList+="clBtnFace, clBtnHighlight, clBtnShadow, clBtnText, clCaptionText, clGrayText, clHighlight" }
   211        { EnumList+="clHighlightText, clInactiveBorder, clInactiveCaption, clInactiveCaptionText, clInfoBk"     }
   212        { EnumList+="clInfoText, clMenu, clMenuText, clScrollBar, clWindow, clWindowFrame, clWindowText"        }
   213        { EnumList+="clDefault, clNone, clAqua, clBlack, clBlue, clDkGray, clFuchsia, clGray, clGreen, clLime"  }
   214        { EnumList+="clLtGray, clMaroon, clNavy, clOlive, clPurple, clRed, clSilver, clTeal, clWhite, clYellow" }
   215        Property Integer piHotTrackColor    clBlue
   216
   217        { DesignTime=False }
   218        Property Boolean Private_pbVisible True
   219        
   220        { DesignTime=False }
   221        Property Boolean Private_pbClick_Valid True
   222        
   223        On_Key kEnter Send KeyAction    //Allow the Enter key to perform the button action
   224    End_Procedure
   225
   226    { MethodType=Event }
   227    Procedure OnCreate
   228        Handle hoFont
   229
   230        Forward Send OnCreate
   231
   232        Set peAppearance        to (Private_peAppearance(Self))
   233        Set piBackColor         to (Private_piBackColor(Self))
   234        Set piBorderGap         to (Private_piBorderGap(Self))
   235        Set pbChecked           to (Private_pbChecked(Self))
   236        Set pbDefault           to (Private_pbDefault(Self))
   237        Set pbDrawFocusRect     to (Private_pbDrawFocusRect(Self))
   238        Set pbEnabled           to (Private_pbEnabled(Self))
   239        Set pbEnableMarkup      to (Private_pbEnableMarkup(Self))
   240        Set pbFlatStyle         to (Private_pbFlatStyle(Self))
   241        Set piForeColor         to (Private_piForeColor(Self))
   242        Set psImage             to (Private_psImage(Self))
   243        Set peImageAlignment    to (Private_peImageAlignment(Self))
   244        Set piImageGap          to (Private_piImageGap(Self))
   245        Set pbMultiLine         to (Private_pbMultiLine(Self))
   246        Set pbRightToLeft       to (Private_pbRightToLeft(Self))
   247        Set peStyle             to (Private_peStyle(Self))
   248        Set peTextAlignment     to (Private_peTextAlignment(Self))
   249        Set peTextImageRelation to (Private_peTextImageRelation(Self))
   250        Set pbUseVisualStyle    to (Private_pbUseVisualStyle(Self))
   251        
   252        #IF (SigCj_Codejock_Version > 130201) 
   253            Set ComControlToolTip   to (Private_psTooltip(Self))
   254        #ENDIF        
   255
   256        //Connect the OCX and dataflex FONT objects and set defaults
   257        Get Private_hoFont   to hoFont
   258        Set pvComObject      of hoFont to (ComFont(Self))    
   259        Set ComBold          of hoFont to (Private_pbBold(Self))
   260        Set ComItalic        of hoFont to (Private_pbItalic(Self))
   261        Set ComStrikethrough of hoFont to (Private_pbStrikethrough(Self))
   262        Set ComUnderline     of hoFont to (Private_pbUnderline(Self))
   263        Set ComName          of hoFont to (Private_psFontName(Self))
   264        Set ComSize          of hoFont to (Private_pnFontSize(Self))
   265
   266        //If Pointer_Only then disable focus rectangle and set Skip_State
   267        
   268        If (pbPointer_Only(Self)) Begin
   269            Set pbDrawFocusRect to False
   270            Set Skip_State to True
   271        End
   272
   273        //This needs to be done after Multiline, so do it at the end incase 
   274        //some of the other properies effect it as well.
   275        Set ComCaption to (Private_psCaption(Self))
   276        // *** Change by Nils G. Svedmyr, 16th of November 2010 ***
   277        #IF (SigCj_Codejock_Version > 130201) 
   278            Send DoChangeTooltipStyle
   279        #ENDIF    
   280    End_Procedure  // OnCreate
   281
   282    // *** Change by Nils G. Svedmyr, 16th of November 2010 ***    
   283    // This sets the tooltip style of the button to the same as DAW's cToolTipController class,
   284    { MethodType=Method } 
   285    Procedure DoChangeTooltipStyle
   286        Handle  hoTooltip hoToolTipController
   287        Variant vTooltip 
   288        Integer iIcon iStyle iWidth
   289        Boolean bBaloon  
   290        String  sTitle
   291 
   292        Get Create (RefClass(cCJToolTipContext)) to hoTooltip          
   293        Get ComToolTipContext to vTooltip
   294        Set pvComObject of hoTooltip to vTooltip
   295        
   296        Get phoToolTipController to hoToolTipController
   297 
   298        If (hoToolTipController > 0) Begin
   299            Get piIcon         of hoToolTipController  to iIcon
   300            Get psTitle        of hoToolTipController  to sTitle
   301            Get piMaxWidth     of hoToolTipController  to iWidth
   302            Get pbBalloonStyle of hoToolTipController  to bBaloon 
   303            If (bBaloon = True) Move xtpToolTipBalloon  to iStyle
   304            Else                Move xtpToolTipStandard to iStyle 
   305        End 
   306        Else Begin
   307            Move xtpToolTipIconInfo to iIcon
   308            Move xtpToolTipStandard to iStyle //xtpToolTipOffice2007                        
   309            Move "Information"      to sTitle
   310        End
   311 
   312        Send ComShowTitleAndDescription of hoTooltip (If((iIcon > 0 or sTitle <> ""),True,False)) iIcon sTitle
   313        If (iWidth > 0) Set ComMaxTipWidth of hoTooltip to iWidth
   314        Set ComStyle of hoTooltip to iStyle  
   315        Send Destroy of hoTooltip
   316    End_Procedure
   317    //-------------------------------------------------------------------------
   318
   319    { MethodType=Property Category="CodeJock" InitialValue=False }
   320    Procedure Set pbBold Boolean bState
   321        Set SigCJProperty Set_Private_pbBold Set_ComBold (Private_hoFont(Self)) to bState
   322    End_Procedure
   323
   324    Function pbBold Returns Boolean
   325        Function_Return (SigCJProperty(Self, Get_Private_pbBold, Get_ComBold, Private_hoFont(Self)))
   326    End_Function
   327
   328    //-------------------------------------------------------------------------
   329
   330    { MethodType=Property Category="CodeJock" InitialValue=False }
   331    Procedure Set pbItalic Boolean bState
   332        Set SigCJProperty Set_Private_pbItalic Set_ComItalic (Private_hoFont(Self)) to bState
   333    End_Procedure
   334
   335    Function pbItalic Returns Boolean
   336        Function_Return (SigCJProperty(Self, Get_Private_pbItalic, Get_ComItalic, Private_hoFont(Self)))
   337    End_Function
   338
   339    //-------------------------------------------------------------------------
   340
   341    { MethodType=Property Category="CodeJock" InitialValue=False }
   342    Procedure Set pbStrikethrough Boolean bState
   343        Set SigCJProperty Set_Private_pbStrikethrough Set_ComStrikethrough (Private_hoFont(Self)) to bState
   344    End_Procedure
   345
   346    Function pbStrikethrough Returns Boolean
   347        Function_Return (SigCJProperty(Self, Get_Private_pbStrikethrough, Get_ComStrikethrough, Private_hoFont(Self)))
   348    End_Function
   349
   350    //-------------------------------------------------------------------------
   351
   352    { MethodType=Property Category="CodeJock" InitialValue=False }
   353    Procedure Set pbUnderline Boolean bState
   354        Set SigCJProperty Set_Private_pbUnderline Set_ComUnderline (Private_hoFont(Self)) to bState
   355    End_Procedure
   356
   357    Function pbUnderline Returns Boolean
   358        Function_Return (SigCJProperty(Self, Get_Private_pbUnderline, Get_ComUnderline, Private_hoFont(Self)))
   359    End_Function
   360
   361    //-------------------------------------------------------------------------
   362
   363    { MethodType=Property Category="CodeJock" InitialValue="MS Sans Serif" }
   364    Procedure Set psFontName String sName
   365        Set SigCJProperty Set_Private_psFontName Set_ComName (Private_hoFont(Self)) to sName
   366    End_Procedure
   367
   368    Function psFontName Returns String
   369        Function_Return (SigCJProperty(Self, Get_Private_psFontName, Get_ComName, Private_hoFont(Self)))
   370    End_Function
   371
   372    //-------------------------------------------------------------------------
   373
   374    { MethodType=Property Category="CodeJock" InitialValue=8.25 }
   375    Procedure Set pnFontSize Number nSize
   376        Set SigCJProperty Set_Private_pnFontSize Set_ComSize (Private_hoFont(Self)) to nSize
   377    End_Procedure
   378
   379    Function pnFontSize Returns Number
   380        Function_Return (SigCJProperty(Self, Get_Private_pnFontSize, Get_ComSize, Private_hoFont(Self)))
   381    End_Function
   382
   383    //-------------------------------------------------------------------------
   384
   385    #IF (SigCj_Codejock_Version < 150001) 
   386        { MethodType=Property Category="CodeJock" InitialValue=OLExtpAppearanceStandard }
   387        { EnumList="OLExtpAppearanceStandard, OLExtpAppearanceFlat, OLExtpAppearanceUltraFlat, OLExtpAppearanceOffice2000, OLExtpAppearanceOffice2000, OLExtpAppearanceOffice2003, OLExtpAppearanceOffice2007" }
   388    #ELSE    
   389        { MethodType=Property Category="CodeJock" InitialValue=OLExtpAppearanceStandard }
   390        { EnumList="OLExtpAppearanceStandard, OLExtpAppearanceFlat, OLExtpAppearanceUltraFlat, OLExtpAppearanceOffice2000, OLExtpAppearanceOffice2000, OLExtpAppearanceOffice2003, OLExtpAppearanceResource" }
   391    #ENDIF 
   392    Procedure Set peAppearance Integer eAppearance
   393        Set SigCJProperty Set_Private_peAppearance Set_ComAppearance to eAppearance
   394    End_Procedure
   395
   396    Function peAppearance Returns Integer
   397        Function_Return (SigCJProperty(Self, Get_Private_peAppearance, Get_ComAppearance ))
   398    End_Function
   399
   400    //-------------------------------------------------------------------------
   401
   402    { MethodType=Property Category="CodeJock" PropertyType=Color InitialValue=clBtnFace }
   403    { EnumList= "cl3DDkShadow, cl3DLight, clActiveBorder, clActiveCaption, clAppWorkSpace, clBackground"    }
   404    { EnumList+="clBtnFace, clBtnHighlight, clBtnShadow, clBtnText, clCaptionText, clGrayText, clHighlight" }
   405    { EnumList+="clHighlightText, clInactiveBorder, clInactiveCaption, clInactiveCaptionText, clInfoBk"     }
   406    { EnumList+="clInfoText, clMenu, clMenuText, clScrollBar, clWindow, clWindowFrame, clWindowText"        }
   407    { EnumList+="clDefault, clNone, clAqua, clBlack, clBlue, clDkGray, clFuchsia, clGray, clGreen, clLime"  }
   408    { EnumList+="clLtGray, clMaroon, clNavy, clOlive, clPurple, clRed, clSilver, clTeal, clWhite, clYellow" }
   409    Procedure Set piBackColor Integer iColor
   410        Set SigCJProperty Set_Private_piBackColor Set_ComBackColor to iColor
   411    End_Procedure
   412
   413    Function piBackColor Returns Integer
   414        Function_Return (SigCJProperty(Self, Get_Private_piBackColor, Get_ComBackColor ))
   415    End_Function
   416
   417    //-------------------------------------------------------------------------
   418
   419    { MethodType=Property Category="CodeJock" InitialValue=4 }
   420    Procedure Set piBorderGap Integer iGap
   421        Set SigCJProperty Set_Private_piBorderGap Set_ComBorderGap to iGap
   422    End_Procedure
   423
   424    Function piBorderGap Returns Integer
   425        Function_Return (SigCJProperty(Self, Get_Private_piBorderGap, Get_ComBorderGap ))
   426    End_Function
   427
   428    //-------------------------------------------------------------------------
   429
   430    { MethodType=Property Category="CodeJock" InitialValue=" " }
   431    Procedure Set psCaption String sCaption
   432        Set SigCJProperty Set_Private_psCaption Set_ComCaption to sCaption
   433    End_Procedure
   434
   435    Function psCaption Returns String
   436        Function_Return (SigCJProperty(Self, Get_Private_psCaption, Get_ComCaption ))
   437    End_Function
   438    
   439    { Visibility=Private Obsolete=True }
   440    // To support standard dataflex button code
   441    Procedure Set Label String sCaption
   442        Set psCaption To sCaption
   443    End_Procedure
   444    // To support standard dataflex button code
   445    { Visibility=Private Obsolete=True }
   446    Function Label Returns String
   447        Function_Return (SigCJProperty(Self, Get_Private_psCaption, Get_ComCaption ))
   448    End_Function
   449    
   450
   451    //-------------------------------------------------------------------------
   452
   453    { MethodType=Property Category="CodeJock" InitialValue=False }
   454    Procedure Set pbChecked Boolean bState
   455        Set SigCJProperty Set_Private_pbChecked Set_ComChecked to bState
   456    End_Procedure
   457
   458    Function pbChecked Returns Boolean
   459        Function_Return (SigCJProperty(Self, Get_Private_pbChecked, Get_ComChecked ))
   460    End_Function
   461
   462    //-------------------------------------------------------------------------
   463
   464    { MethodType=Property Category="CodeJock" InitialValue=False }
   465    Procedure Set pbDefault Boolean bState
   466        Set SigCJProperty Set_Private_pbDefault Set_ComDefault to bState
   467    End_Procedure
   468
   469    Function pbDefault Returns Boolean
   470        Function_Return (SigCJProperty(Self, Get_Private_pbDefault, Get_ComDefault ))
   471    End_Function
   472
   473    { Visibility=Private Obsolete=True }
   474    // *** Added by Nils G. Svedmyr *** 19 Nov 2010
   475    // To support standard dataflex button code
   476    Procedure Set Default_State Boolean bState
   477        Set pbDefault to bState
   478    End_Procedure
   479    { Visibility=Private Obsolete=True }
   480    // *** Added by Nils G. Svedmyr *** 19 Nov 2010
   481    // To support standard dataflex button code
   482    Function Default_State Returns Boolean
   483        Function_Return (pbDefault(Self))
   484    End_Function
   485
   486    //-------------------------------------------------------------------------
   487
   488    { MethodType=Property Category="CodeJock" InitialValue=True }
   489    Procedure Set pbDrawFocusRect Boolean bState
   490        Set SigCJProperty Set_Private_pbDrawFocusRect Set_ComDrawFocusRect to bState
   491    End_Procedure
   492
   493    Function pbDrawFocusRect Returns Boolean
   494        Function_Return (SigCJProperty(Self, Get_Private_pbDrawFocusRect, Get_ComDrawFocusRect ))
   495    End_Function
   496
   497    //-------------------------------------------------------------------------
   498
   499    { MethodType=Property Category="CodeJock" InitialValue=True }
   500    Procedure Set pbEnabled Boolean bState
   501        Set SigCJProperty Set_Private_pbEnabled Set_ComEnabled to bState
   502    End_Procedure
   503
   504    Function pbEnabled Returns Boolean
   505        Function_Return (SigCJProperty(Self, Get_Private_pbEnabled, Get_ComEnabled ))
   506    End_Function
   507    
   508    { Visibility=Private Obsolete=True }
   509    // *** Added by Nils G. Svedmyr *** 19 Nov 2010
   510    // To support standard dataflex button code
   511    Procedure Set Enabled_State Integer bState
   512        Set pbEnabled to bState    
   513    End_Procedure
   514 
   515    { Visibility=Private Obsolete=True }
   516    // *** Added by Nils G. Svedmyr *** 19 Nov 2010
   517    // To support standard dataflex button code
   518    Function Enabled_State Returns Integer
   519        Function_Return (pbEnabled(Self))
   520    End_Function
   521    
   522    //-------------------------------------------------------------------------
   523
   524    { MethodType=Property Category="CodeJock" InitialValue=False }
   525    Procedure Set pbEnableMarkup Boolean bState
   526        Set SigCJProperty Set_Private_pbEnableMarkup Set_ComEnableMarkup to bState
   527    End_Procedure
   528
   529    Function pbEnableMarkup Returns Boolean
   530        Function_Return (SigCJProperty(Self, Get_Private_pbEnableMarkup, Get_ComEnableMarkup ))
   531    End_Function
   532
   533    //-------------------------------------------------------------------------
   534
   535    { MethodType=Property Category="CodeJock" InitialValue=False }
   536    Procedure Set pbFlatStyle Boolean bState
   537        Set SigCJProperty Set_Private_pbFlatStyle Set_ComFlatStyle to bState
   538    End_Procedure
   539
   540    Function pbFlatStyle Returns Boolean
   541        Function_Return (SigCJProperty(Self, Get_Private_pbFlatStyle, Get_ComFlatStyle ))
   542    End_Function
   543
   544    //-------------------------------------------------------------------------
   545
   546    { MethodType=Property Category="CodeJock" PropertyType=Color InitialValue=clWindowText }
   547    { EnumList= "cl3DDkShadow, cl3DLight, clActiveBorder, clActiveCaption, clAppWorkSpace, clBackground"    }
   548    { EnumList+="clBtnFace, clBtnHighlight, clBtnShadow, clBtnText, clCaptionText, clGrayText, clHighlight" }
   549    { EnumList+="clHighlightText, clInactiveBorder, clInactiveCaption, clInactiveCaptionText, clInfoBk"     }
   550    { EnumList+="clInfoText, clMenu, clMenuText, clScrollBar, clWindow, clWindowFrame, clWindowText"        }
   551    { EnumList+="clDefault, clNone, clAqua, clBlack, clBlue, clDkGray, clFuchsia, clGray, clGreen, clLime"  }
   552    { EnumList+="clLtGray, clMaroon, clNavy, clOlive, clPurple, clRed, clSilver, clTeal, clWhite, clYellow" }
   553    Procedure Set piForeColor Integer iColor
   554        Set SigCJProperty Set_Private_piForeColor Set_ComForeColor to iColor
   555    End_Procedure
   556
   557    Function piForeColor Returns Integer
   558        Function_Return (SigCJProperty(Self, Get_Private_piForeColor, Get_ComForeColor ))
   559    End_Function
   560
   561    //-------------------------------------------------------------------------
   562
   563    { MethodType=Property Category="CodeJock" InitialValue=OLExtpAlignCenter }
   564    { EnumList="OLExtpAlignLeft, OLExtpAlignRight, OLExtpAlignCenter, OLExtpAlignMiddle, OLExtpAlignTop, OLExtpAlignBottom" }
   565    Procedure Set peImageAlignment Integer eAlign
   566        Set SigCJProperty Set_Private_peImageAlignment Set_ComImageAlignment to eAlign
   567    End_Procedure
   568
   569    Function peImageAlignment Returns Integer
   570        Function_Return (SigCJProperty(Self, Get_Private_peImageAlignment, Get_ComImageAlignment ))
   571    End_Function
   572
   573    //-------------------------------------------------------------------------
   574
   575    { MethodType=Property Category="CodeJock" InitialValue=3 }
   576    Procedure Set piImageGap Integer iGap
   577        Set SigCJProperty Set_Private_piImageGap Set_ComImageGap to iGap
   578    End_Procedure
   579
   580    Function piImageGap Returns Integer
   581        Function_Return (SigCJProperty(Self, Get_Private_piImageGap, Get_ComImageGap ))
   582    End_Function
   583
   584    //-------------------------------------------------------------------------
   585
   586    { MethodType=Property Category="CodeJock" InitialValue=False }
   587    Procedure Set pbMultiLine Boolean bState
   588        Set SigCJProperty Set_Private_pbMultiLine Set_ComMultiLine to bState
   589    End_Procedure
   590
   591    Function pbMultiLine Returns Boolean
   592        Function_Return (SigCJProperty(Self, Get_Private_pbMultiLine, Get_ComMultiLine ))
   593    End_Function
   594
   595    //-------------------------------------------------------------------------
   596
   597    { MethodType=Property Category="CodeJock" InitialValue=False }
   598    Procedure Set pbRightToLeft Boolean bState
   599        Set SigCJProperty Set_Private_pbRightToLeft Set_ComRightToLeft to bState
   600    End_Procedure
   601
   602    Function pbRightToLeft Returns Boolean
   603        Function_Return (SigCJProperty(Self, Get_Private_pbRightToLeft, Get_ComRightToLeft ))
   604    End_Function
   605
   606    //-------------------------------------------------------------------------
   607
   608    { MethodType=Property Category="CodeJock" InitialValue=OLExtpButtonNormal }
   609    { EnumList="OLExtpButtonNormal, OLExtpButtonDropDown, OLExtpButtonDropDownRight, OLExtpButtonSplitDropDown" }
   610    Procedure Set peStyle Integer eStyle
   611        Set SigCJProperty Set_Private_peStyle Set_ComStyle to eStyle
   612    End_Procedure
   613
   614    Function peStyle Returns Integer
   615        Function_Return (SigCJProperty(Self, Get_Private_peStyle, Get_ComStyle ))
   616    End_Function
   617
   618    //-------------------------------------------------------------------------
   619
   620    { MethodType=Property Category="CodeJock" InitialValue=OLExtpAlignCenter }
   621    { EnumList="OLExtpAlignLeft, OLExtpAlignRight, OLExtpAlignCenter, OLExtpAlignMiddle, OLExtpAlignTop, OLExtpAlignBottom" }
   622    Procedure Set peTextAlignment Integer eAlign
   623        Set SigCJProperty Set_Private_peTextAlignment Set_ComTextAlignment to eAlign
   624    End_Procedure
   625
   626    Function peTextAlignment Returns Integer
   627        Function_Return (SigCJProperty(Self, Get_Private_peTextAlignment, Get_ComTextAlignment ))
   628    End_Function
   629
   630    //-------------------------------------------------------------------------
   631
   632    { MethodType=Property Category="CodeJock" InitialValue=OLExtpImageBeforeText }
   633    { EnumList="OLExtpOverlay, OLExtpImageAboveText, OLExtpTextAboveImage, OLExtpImageBeforeText, OLExtpTextBeforeImage" }
   634    Procedure Set peTextImageRelation Integer ePosition
   635        Set SigCJProperty Set_Private_peTextImageRelation Set_ComTextImageRelation to ePosition
   636    End_Procedure
   637
   638    Function peTextImageRelation Returns Integer
   639        Function_Return (SigCJProperty(Self, Get_Private_peTextImageRelation, Get_ComTextImageRelation ))
   640    End_Function
   641
   642    //-------------------------------------------------------------------------
   643
   644    { MethodType=Property Category="CodeJock" InitialValue=True }
   645    Procedure Set pbUseVisualStyle Boolean bState
   646        Set SigCJProperty Set_Private_pbUseVisualStyle Set_ComUseVisualStyle to bState
   647    End_Procedure
   648
   649    Function pbUseVisualStyle Returns Boolean
   650        Function_Return (SigCJProperty(Self, Get_Private_pbUseVisualStyle, Get_ComUseVisualStyle ))
   651    End_Function
   652
   653    //-------------------------------------------------------------------------
   654 
   655    { MethodType=Property Category="CodeJock" InitialValue=" " }
   656    Procedure Set psToolTip String sTooltip
   657        #IF (SigCj_Codejock_Version > 130201) 
   658        Set SigCJProperty Set_Private_psTooltip Set_ComControlToolTip to sTooltip
   659        #ENDIF
   660    End_Procedure
   661
   662    Function psTooltip Returns String
   663        #IF (SigCj_Codejock_Version > 130201) 
   664        Function_Return (SigCJProperty(Self, Get_Private_psTooltip, Get_ComControlToolTip ))
   665        #ENDIF
   666    End_Function
   667
   668
   669    //-------------------------------------------------------------------------
   670    { MethodType=Property Category="CodeJock" InitialValue="" }
   671    Procedure Set psImage String sImage
   672        Integer iImageId
   673        Variant vImage
   674
   675        Set Private_psImage to sImage
   676
   677        If (IsComObjectCreated(Self)) Begin
   678            Get AddImage    of ghoSigCjGlobalSetting sImage 0 OLExtpImageNormal to iImageId
   679            Get ImageFromId of ghoSigCjGlobalSetting iImageId to vImage
   680
   681            Set ComIcon to vImage
   682        End
   683    End_Procedure
   684
   685    Function psImage Returns String
   686        Function_Return (Private_psImage(Self))
   687    End_Function
   688
   689    //=========================================================================
   690
   691    //Some ActiveX controls do not honour the Visibe_State message event though 
   692    //they're in the parent class (this is one). So we need to use the low 
   693    //level windows message ShowWindow to hide/Show the button.  We also need 
   694    //to change the focus mode so the button can't take the focus via keyboard
   695    //navigation when invisible.
   696
   697    { MethodType=Property Category=Codejock InitialValue=True }
   698    Procedure Set pbVisible Boolean bVisible
   699        Integer iVoid
   700
   701        If (bVisible) Set Focus_Mode to Focusable
   702        Else          Set Focus_Mode to NonFocusable
   703        
   704        If (IsComObjectCreated(Self)) Move (ShowWindow(ComHWnd(Self),bVisible)) to iVoid
   705        Set Private_pbVisible to bVisible
   706    End_Procedure
   707
   708    Function pbVisible Returns Boolean
   709        Function_Return (Private_pbVisible(Self))
   710    End_Function
   711
   712    //-------------------------------------------------------------------------
   713    //Augment Add_Focus to update the visible state. This has to be done after 
   714    //the control has been painted to the screen
   715
   716    Procedure Add_Focus Handle ohParent Returns Integer
   717        Integer iVoid iRetval
   718        
   719        Forward Get Msg_Add_Focus ohParent to iRetval
   720
   721        Move (ShowWindow(ComHWnd(Self), Private_pbVisible(Self))) to iVoid
   722        If (pbEnableHotTrack(Self)) Set ComForeColor to (Private_piForeColor(Self))
   723
   724        Procedure_Return iRetval
   725    End_Procedure // Add_Focus
   726
   727    //-------------------------------------------------------------------------
   728    //Keyboard methods / events
   729
   730    //Handle Enter Key (OnKey message in Construct_Object)
   731    Procedure KeyAction
   732        If (pbVisible(Self) and pbEnabled(Self)) Send OnClick
   733    End_Procedure
   734
   735//Martin -  Is KeyPress needed? If the button has the focus then the only valid
   736//          key is entered and that is handled by the OnKey message. Any other 
   737//          navigation keys (esc arrows tab etc) should be handled by the vdf 
   738//          runtime.
   739
   740//    Procedure OnKeyPress Integer ByRef iKey
   741//    End_Procedure
   742//
   743//    Procedure OnComKeyPress Short ByRef llKeyAscii
   744//        Send OnKeyPress llKeyAscii
   745//    End_Procedure
   746    
   747    //-------------------------------------------------------------------------
   748    //Mouse methods / events
   749
   750    Procedure OnClick
   751    End_Procedure
   752
   753    Procedure OnComClick
   754        If (Private_pbClick_Valid(Self)) Send OnClick        
   755    End_Procedure
   756    
   757//Martin -  Toms' code uses OnMouseMove. The VDF 14.1 help shows this to be a 
   758//          valid method, but with different parameters. So I have changed the
   759//          name to MouseMove. Also do we need an event for mouse move or can 
   760//          this just be coded in the OnComMouseMove?
   761
   762    //Augmented for Hot Tracking
   763    Procedure MouseMove Integer iButton Integer iShift Integer iX Integer iY
   764        If (pbEnableHotTrack(Self) and pbEnabled(Self)) Begin
   765            If (iX = -1 and iY = -1) Set ComForeColor to (Private_piForeColor(Self))
   766            Else Set ComForeColor to (piHotTrackColor(Self))
   767        End
   768    End_Procedure
   769
   770    Procedure OnComMouseMove Short iButton Short iShift OLE_XPOS_PIXELS iX OLE_YPOS_PIXELS iY
   771        Send MouseMove iButton iShift iX iY
   772    End_Procedure
   773
   774//Martin -  Ditto - See comments for MouseMove
   775
   776    // Need to make sure the button can take the focus, i.e. exiting of the current
   777    // focusable object is successful - this is a DAW bug where the focus is not being moved
   778    // correctly when using the mouse to click the Codejock button
   779
   780    Procedure MouseDown Integer iButton Integer iShift Integer iX Integer iY
   781        Integer iRetval
   782
   783        Set phoReturn_Focus to (Focus(Self))
   784        Get Msg_Activate to iRetval
   785        Set Private_pbClick_Valid to (iRetval = DF_SUCCESS)
   786    End_Procedure 
   787
   788    Procedure OnComMouseDown Short iButton Short iShift OLE_XPOS_PIXELS iX OLE_YPOS_PIXELS iY
   789        Send MouseDown iButton iShift iX iY
   790    End_Procedure // OnComMouseDown
   791
   792
   793//Martin -  Ditto - See comments for MouseMove
   794    // After we click and the check if the click was valid. If it wasn't then force the client
   795    // (view/panel etc.) to redraw where the focus currently is (the object we clicked from) else
   796    // Move the focus back To where it came From If Pointer only AND the focus is on the button
   797    // OR thinks it's where we came from.  Note we need to activate the button and then the prior 
   798    // Object as DAW sometimes believes the focus can be two places at once.
   799
   800    Procedure MouseUp Integer iButton Integer iShift Integer iX Integer iY
   801        If (not(Private_pbClick_Valid(Self))) Send Mouse_Down of (Parent(Self)) 1 1
   802        Else If (pbPointer_Only(Self)) Begin
   803            If (Focus(Self) = Self or Focus(Self) = phoReturn_Focus(Self)) Begin
   804                Send Activate
   805                Send Activate of (phoReturn_Focus(Self))
   806            End
   807        End
   808    End_Procedure 
   809
   810    Procedure OnComMouseUp Short iButton Short iShift OLE_XPOS_PIXELS iX OLE_YPOS_PIXELS iY
   811        Send MouseUp iButton iShift iX iY
   812    End_Procedure 
   813
   814    //=========================================================================
   815    
   816    Function  Absolute_GuiOrigin Returns Integer
   817        Handle hWnd
   818        Integer iRow iCol iVoid iLocation
   819        String  sRect
   820        Pointer P_sRect
   821
   822        Get ComHWnd to hWnd
   823        ZeroType tRECT to sRect
   824        GetAddress of sRect to P_sRect
   825        Move (GetWindowRect(hWnd, P_sRect)) to iVoid
   826        GetBuff from sRect At tRECT.left   to iCol
   827        GetBuff from sRect At tRECT.top    to iRow
   828        Function_Return ((iRow * 65536) + iCol)            
   829    End_Function
   830
   831    Procedure OnComDropDown
   832        Integer iLoc iSize
   833
   834        If (not(Private_pbInDropDown(Self)) and (phoDropDownMenu(Self) <> 0)) Begin
   835            Set Private_pbInDropDown to True
   836            Get Absolute_GuiOrigin to iLoc
   837            Get GuiSize to iSize
   838
   839            Send DropDown of (phoDropDownMenu(Self)) (((Hi(iLoc) + Hi(iSize)) * 65536) + Low(iLoc)) (Low(iSize))
   840            Set Private_pbInDropDown to False
   841        End
   842    End_Procedure
   843
   844End_Class
   845
   846//==============================================================================
   847//End of package - cSigCJPushButton.pkg
   848//==============================================================================
   849