Module cEdit_mixin.pkg

     1// cEdit_mixin.pkg
     2//
     3// mixin used by both cRichEdit and cTextEdit
     4Use Windows.pkg
     5
     6// for undoType and RedoType
     7Enum_List
     8    Define utUnknown
     9    Define utTyping
    10    Define utDelete
    11    Define utDragDrop
    12    Define utCut
    13    Define utPaste
    14End_Enum_List
    15
    16{ ClassType=Mixin }
    17Class cEdit_Mixin Is A Mixin
    18
    19    { Visibility=Private }
    20    Procedure Define_cEdit_Mixin
    21        Send Define_Standard_Object_Mixin
    22        Send Define_Dflabel_Mixin
    23        Send Define_ToolTip_Support_Mixin
    24
    25        Set Label_Offset To 1 0
    26        Set Label_Justification_Mode To Jmode_Top
    27        Set pbUseFormWindowHandle to False     // Must come after Define_ToolTip_Support_Mixin
    28        Set Color     to clWindow      // should be the default...also system colors don't work
    29        Set TextColor to clWindowText  // should be the default
    30
    31        { DesignTime=False }
    32        Property boolean Changed_State False
    33
    34        { Visibility=Private }
    35        Property Integer pbSuppressChange False
    36
    37        { Visibility=Private }
    38        Property integer piPriorEnabledColor 0 // private, used by shadow_display
    39
    40        Send Define_Shadow_Mixin
    41
    42        { Category=Appearance }
    43        Property Integer Floating_Menu_Object Default_Form_Floating_Menu_Id
    44
    45        on_key kEnter send default_key
    46
    47        Set Disable_default_action_button_state to True
    48
    49    End_Procedure // Define_cEdit_Mixin
    50
    51    Import_Class_Protocol Standard_Object_Mixin
    52    Import_Class_Protocol Dflabel_Mixin
    53    Import_Class_Protocol Shadow_Mixin
    54    Import_Class_Protocol ToolTip_Support_Mixin
    55
    56    // currently there is no built in context menu support (old edit has one).
    57    { MethodType=Event  NoDoc=True }
    58    Procedure Mouse_Down2 Integer iWindowNumber Integer iPosition
    59        integer obj rval
    60        Forward Send mouse_down2 iWindowNumber iPosition
    61        Get Floating_Menu_object to obj
    62        if obj Begin
    63            If (Focus(desktop)<>Self) Begin
    64                get msg_Activate to rval
    65            End
    66            If (Focus(desktop)=Self) Begin
    67                Send Popup to obj
    68            End
    69        end
    70    End_Procedure // Mouse_down2
    71
    72    { MethodType=Property  NoDoc=True }
    73    Function Object_Shadow_State returns integer
    74       Function_Return (Private.Shadow_State(self))
    75    End_Function // Object_Shadow_State
    76
    77    // enables or disables an active window. Allows enabled_state to be used after object is paged
    78    { Visibility=Private }
    79    Procedure Enable_Window integer iState
    80        handle hWnd
    81        Get Window_Handle to hWnd
    82        If hWnd ;
    83            Move (EnableWindow(hWnd,iState)) To hWnd
    84    End_procedure
    85
    86    { MethodType=Property Visibility=Private }
    87    Procedure Set Current_Shadow_State integer iState
    88       Set Private.Shadow_State to iState     // used by get object_shadow_state/enabled_state
    89       Set Window_Style To WS_DISABLED iState // used to set style before the object is paged
    90       Send Enable_Window (Not(iState))       // used to enable/disable after object is paged
    91    End_Procedure // Set Object_Shadow_State
    92
    93
    94    { MethodType=Event }
    95    Procedure Shadow_Display
    96        // control will take care of shadowing itself
    97        Send Label_Shadow_Display // if object has a label text box, handle disabling this
    98    End_Procedure // Shadow_Display
    99
   100    { MethodType=Property Visibility=Private }
   101    Procedure Set Item_Shadow_State integer iItem integer iState
   102    End_Procedure // Set Item_Shadow_State
   103
   104    { MethodType=Property Visibility=Private }
   105    Function Item_Shadow_State integer iItem Returns integer
   106    End_Function // Item_Shadow_State
   107
   108    { MethodType=Event }
   109    Procedure OnChange
   110    End_Procedure
   111
   112    { MethodType=Event }
   113    Procedure OnMaxText
   114    End_Procedure
   115
   116    { Visibility=Private MethodType=Event }
   117    Procedure Command Integer wParam Integer lParam
   118        integer iParam
   119        Forward Send Command wParam lParam
   120        Move (hi(wParam)) to iParam
   121        If (iParam=EN_CHANGE) Begin
   122            // if we are supressing change notification, do nothing.
   123            If (pbSuppressChange(self)) Procedure_return
   124            If not (changed_state(self)) begin
   125                Set Changed_state to true
   126            end
   127            Send OnChange
   128        End
   129        else If (iParam=EN_MAXTEXT) Begin
   130            Send OnMaxText
   131        End
   132    End_Procedure
   133
   134    // Some messages trigger the command message with a change event. In some circumstances we must suppress this.
   135    // The delete_data message and the page message both do this.
   136
   137    { NoDoc=True }
   138    procedure Delete_Data
   139        Boolean bWas
   140        Get pbSuppressChange to bWas
   141        Set pbSuppressChange to True // Delete_Data sends command which triggers change. We suppress that here
   142        forward send delete_data
   143        set changed_state to false
   144        Send OnChange
   145        Set pbSuppressChange to bWas
   146    end_procedure
   147
   148    { NoDoc=True }
   149    procedure Page integer iState
   150        Boolean bWas
   151        Get pbSuppressChange to bWas
   152        Set pbSuppressChange to true  // Page sends command which triggers change. We suppress that here
   153        Forward Send Page iState
   154        Set pbSuppressChange to bWas
   155    end_procedure
   156
   157
   158    Procedure AppendTextLn string sText
   159        Send AppendText sText
   160        Send AppendText (character(10))
   161    End_Procedure
   162
   163    // Called by Page_Object. Handles tooltip creation. We use a dedicated
   164    // method to perform AddToolTip because it is often the case that Page_Object
   165    // is implemented in a mixin class.
   166    { Visibility=Private }
   167    Procedure RequestAddToolTip
   168        Send AddToolTip
   169    End_Procedure  // RequestAddToolTip
   170
   171
   172    // Called by Page_Object. Handles tooltip removal. 
   173    { Visibility=Private }
   174    Procedure RequestDeleteToolTip
   175        Send DeleteToolTip
   176    End_Procedure // RequestDeleteToolTip
   177End_Class
   178