Module Val_mx.pkg

     1//************************************************************************
     2//
     3// Confidential Trade Secret.
     4// Copyright 1987-1997 Data Access Corporation, Miami FL, USA
     5// All Rights reserved
     6// DataFlex is a registered trademark of Data Access Corporation.
     7//
     8//************************************************************************
     9
    10//************************************************************************
    11// Val_mx.pkg
    12// Version: 1.0 for DAF 1.1
    13// Copyright (c) 1994 Data Access Corporation
    14//
    15// 05/02/94  - created
    16//
    17// Author: John J. Tuohy
    18//
    19// Augmentations:
    20//    Validate_items
    21//    Next
    22//
    23//
    24// Val_MX.pkg  - Validate Mixin for alternate validation capabilities.
    25//
    26// 1. Validate_All_Items_State property - Is set TRUE during a save
    27//      validation and false during a navigation validation. Let's developer
    28//      take different actions based on a save validate and a navigate
    29//      validate.
    30//
    31// 2. Validate_Mode - Determines when validations are sent.
    32//        VALIDATE_DEFAULT       Works the way it does now. Validates
    33//                               occur if Object_Validation is TRUE
    34//                               (which is the default). This means that
    35//                               validates normally occur during
    36//                               downward navigation and save (when
    37//                               Validate_Items is sent by DSO).
    38//
    39//        VALIDATE_ON_SAVE       Validates are only sent during a save.
    40//                               When this property is set
    41//                               object_validation is also set FALSE. It
    42//                               is only turned on inside of
    43//                               Validate_Items.
    44//
    45//        VALIDATE_ON_SAVE_NEXT  Validates are only sent during a save
    46//                               and during NEXT navigation (ENTER and
    47//                               TAB). When this property is set
    48//                               object_validation is also set FALSE. It
    49//                               is only turned on inside of
    50//                               Validate_Items and Next messages.
    51//
    52//        Note: When this property is SET the Obvject_Validation
    53//              property is also set. It is set TRUE if mode is set to
    54//              VALIDATE_DEFAULT, else it is set False. It is not
    55//              expected that you will dynamically change the
    56//              Validate_Mode property. You'll probably set it once,
    57//              when the object is created.
    58//
    59//
    60// 12/22/94 JJT - Added code from server.pkg to validate_items.
    61// 05/25/95 JJT - Created Object_item_Validation sets object_validation.
    62//************************************************************************
    63// 11/11/95 JJT - Validate Items now sends a smarter activate message
    64//                Activate_area (also defined here).
    65//************************************************************************
    66use VDFBase.pkg
    67
    68enum_list
    69    Define VALIDATE_DEFAULT
    70    Define VALIDATE_ON_SAVE
    71    Define VALIDATE_ON_SAVE_NEXT
    72end_enum_list
    73
    74Class Validate_Mixin is a mixin
    75     { MethodType=Event Visibility=Private }
    76     Procedure Define_Validate
    77        { Category=Data }
    78        { PropertyType=Boolean }
    79        Property Integer Validate_All_Items_State  False
    80        { Visibility=Private }
    81        Property Integer Private.Validate_mode     VALIDATE_DEFAULT
    82     End_Procedure // Construct_Object
    83
    84     //  Get/Set Validate_Mode: When SET also set object_Validation
    85     //                         property
    86     //
    87     { MethodType=Property }
    88     Function Validate_Mode Returns Integer
    89       Function_Return (Private.Validate_Mode(self))
    90     End_Function // Validate_Mode
    91
    92     { MethodType=Property }
    93     { EnumList="Validate_Default, Validate_On_Save, Validate_On_Save_Next" }
    94     { InitialValue=Validate_On_Save_Next }
    95     { Category=Data }
    96     Procedure Set Validate_Mode Integer Mode
    97        Set Private.Validate_Mode to Mode
    98        Set Object_Validation to (If(Mode=VALIDATE_DEFAULT,TRUE,FALSE))
    99     End_Procedure // Set Validate_mode
   100
   101     //  1) If Validate_mode is SAVE or SAVE_NEXT then make sure that the
   102     //     validations occur (set object_validation to TRUE). If the mode is
   103     //     DEFAULT the property is probably already true.
   104     //
   105     //  2) Set Validate_All_Items_State to T. Validate handlers can query this
   106     //     property to determine if a validate is due to navigation or saving
   107     //
   108    Function Validate_Items Boolean bNotFindReq Returns Integer
   109        integer rVal oldval VAI
   110        integer oldautotop
   111        Get Validate_all_Items_State to VAI     // what it was s/b False
   112        Set Validate_all_Items_State to TRUE    // what it is now!
   113        If (Validate_Mode(self)<>VALIDATE_DEFAULT) Begin
   114           get object_validation to oldval
   115           Set object_validation to TRUE
   116           Forward Get Validate_items bNotFindReq to rVal
   117           Set object_validation to oldval
   118        End
   119        Else ;
   120           Forward Get Validate_items bNotFindReq to rVal
   121        Set Validate_all_Items_State to VAI     //Restore
   122
   123        // if validate failed make sure that this object now has
   124        // the focus. This code had been in server.pkg
   125        //
   126        if (rVal <> 0 AND focus(desktop) <> self) begin
   127           get auto_top_item_state to oldautotop
   128           set auto_top_item_state to false
   129           // **JJT(3)** modified to handle popups and objects inside of popups.
   130           send activate_area TRUE //take focus w/out changing current_item
   131           //send activate  //take focus w/out changing current_item
   132           set auto_top_item_state to oldautotop
   133        end
   134        function_return rVal
   135     End_Function // Validate_items
   136
   137
   138     //  1) If Validate_mode is SAVE_NEXT then make sure that the
   139     //     validations occur (set object_validation to TRUE). If the mode is
   140     //     DEFAULT the property is probably already true. This insures that
   141     //     validates occur during "procedural" data-entry (pressing enter or
   142     //     tab) but not during event-driven data-entry
   143     //
   144     Procedure Next
   145        integer oldval
   146        If (Validate_Mode(self)=VALIDATE_ON_SAVE_NEXT) Begin
   147           get object_validation to oldval
   148           Set object_validation to TRUE
   149           Forward Send Next
   150           Set object_validation to oldval
   151        End
   152        Else ;
   153           Forward Send Next
   154     End_Procedure // Next
   155
   156     // Set object_validation. This is sent to the focus object through
   157     // entry_clear/clear_all. All objects understand this message but only
   158     // item based (entry_form and table) objects uses this. See Deodlgmx.pkg
   159     { MethodType=Property Visibility=Private }
   160     Procedure Set Object_Item_validation integer fg
   161       Set Object_Validation to Fg
   162     End_Procedure
   163
   164     { MethodType=Property Visibility=Private }
   165     Function Object_Item_Validation returns integer
   166       Function_return (Object_Validation(self))
   167     End_Function
   168
   169End_Class
   170
   171