Module Dbbitmap.pkg

     1//*******************************************************************
     2//
     3// Confidential Trade Secret.
     4// Copyright (c) 1997 Data Access Corporation, Miami Florida
     5// All rights reserved.
     6// DataFlex is a registered trademark of Data Access Corporation.
     7//
     8//*******************************************************************
     9//
    10// File       : dbBitmap.pkg
    11// Version    : 2.0
    12//
    13// Created    : 10/10/96
    14//
    15//            : DbBitmap class - data aware bitmap container
    16//
    17// Author     : Michael Salzlechner / John Tuohy
    18//
    19// Rem        : Bitmap the filename of a
    20//            : bitmap in MS-Windows BMP-Format.
    21//            : This class will automatically display
    22//            : the stored bitmap when finding a record
    23//            : Mouseclick on the object starts a common
    24//            : filedialog to set a new bitmap
    25//            : File name is bmap is stored and retrieved from appropriate
    26//              data-fill
    27//
    28//  Object xxx is a dbBitMap
    29//      entry_Item File.Field // name of bitmap
    30//      Set Size to height width
    31//      Set Location to column row
    32//      Set Store_with_Pathname_State to True|False
    33//      Set NoPut_State  to True |False
    34//      Set Bitmap_Style to Style
    35//      Set Allow_Select_Bitmap_State to True | False
    36//      Set Dialog_Caption to "Name of for common file dialog"
    37//      Set Initial_Folder to "intitial file directory"
    38//  End_object
    39//
    40//  Bitmap-styles are BITMAP_ACTUAL
    41//                    BITMAP_STRETCH
    42//                    BITMAP_TILE
    43//                    BITMAP_CENTER
    44//
    45//  Function Select_Bitmap returns string
    46//
    47//      By default this pops up a common file dialog allowing user to
    48//      select a bitmap. This is suitable for augmentation. Return the
    49//      file name of the bitmap to use. Invoked by double click.
    50//
    51//*******************************************************************
    52// 2/26/2002  JJT - 8.2 clean up (indirect_file, local, self, etc.)
    53
    54Use DfBitmap.pkg
    55
    56Use Nesting.pkg
    57Use Navigate.pkg
    58Use Server.pkg
    59use refmodes.pkg    // refresh mode constants
    60
    61{ DataBindable=True }
    62{ HelpTopic=dbBitmap }
    63{ OverrideProperty=Allow_Select_Bitmap_State InitialValue=True }
    64Class dbBitmap is a BitmapContainer
    65
    66  IMPORT_CLASS_PROTOCOL Nesting_Mixin
    67  IMPORT_CLASS_PROTOCOL Navigate_Mixin
    68  IMPORT_CLASS_PROTOCOL Server_Mixin
    69
    70  Procedure Construct_Object
    71    Forward Send Construct_Object
    72
    73    { Visibility=Private }
    74    Property integer Private.Data_File        0
    75
    76    { Visibility=Private }
    77    Property integer Private.Data_Field       0
    78
    79    send define_nesting     //invoke DEO nesting standard support constructor
    80    send define_navigation  //invoke DEO navigation standard support constructor
    81    send define_server      //invoke Server support constructor
    82
    83    // This Property indicates if we should store the full pathname
    84    { Category=Behavior }
    85    Property Integer Store_With_Pathname_State 0
    86
    87    // indicates if this should be a noput field
    88    { Category=Behavior }
    89    { PropertyType=Boolean }
    90    Property Integer NoPut_State              False // just like items
    91
    92    set Allow_Select_Bitmap_State to True   // allow dynamic selection of bitmap
    93  End_Procedure
    94
    95  //  It is unlikely you'll need to validate "items" in this bitmap
    96  //  class but you could...
    97  //
    98  { Visibility=Private }
    99  function Validate_Items Integer Fg returns integer
   100  end_function
   101
   102  //
   103  // created for EntItem simulation and Server support:
   104  //  if file# = 0, display only if Target_File is in Done-array
   105  //  else display only if file# = Target_File
   106  //
   107  { Visibility=Private }
   108  procedure Entry_Display integer file# integer flag
   109    integer dFile dField
   110    String sVal
   111    get Data_File  to dFile
   112    get Data_Field to dField
   113    //
   114    //  We will display this if the following conditions exist:
   115    //    passed file is 0 and the target file is in the done array <or>
   116    //    passed file= target File or flag = true)
   117    if file# eq 0 is_file_included dFile 1  // set found if in done array
   118    else indicate found as (file# = dFile OR flag = TRUE)
   119    [Found] begin
   120       Send Read_Data
   121       Set Changed_State to False
   122    End
   123  End_procedure
   124
   125  //
   126  // created for EntItem simulation: file# <> 0 means use Cleared-array
   127  //
   128  { Visibility=Private }
   129  procedure Entry_Clear integer file#
   130    Indicate Found as File# eq 0
   131    [Not Found] Is_file_included (Data_File(self,0)) 0 //0=clear arry
   132    [Found] Begin
   133       Send Clear_Data
   134       Set Changed_State to False
   135    end
   136  end_procedure
   137
   138  //
   139  // created for EntItem simulation:
   140  //
   141  { Visibility=Private }
   142  procedure Entry_Clear_All integer file#
   143    Send Entry_Clear File#
   144  end_procedure
   145
   146  //
   147  // created for EntItem simulation and Server support
   148  //
   149  //  Normally entry_update gets called during saves and finds. When
   150  //     Save:  file#  = 0   flag = 3
   151  //     Find:  file# <> 0   flag = 1
   152  //
   153  //  Allow Update Rules:
   154  //    if Save update (file#=0, flag=3)
   155  //       Allow Update if not noput and Target_File is in Done-array
   156  //                    and (new record or changed_state).
   157  //    else if Find_Update (file#=Target_File, Flag=1) or misc (file#=0)
   158  //       perform update
   159  //
   160  //  Modified so that an unchanged item is moved to the field if
   161  //  the main file is a new record.
   162  //
   163  { Visibility=Private }
   164  procedure Entry_Update integer file# integer flag
   165    integer dFile dField C_Item Srvr# ok
   166    integer iStat
   167    String sValue
   168
   169    Get Server     to Srvr#
   170    Get Data_File  to dFile
   171    Get Data_Field to dField
   172
   173    if (file# = 0 AND flag = 3) Begin
   174       // this should be a save a record update.check for no put
   175       If (noput_state(self)) Indicate Found False
   176       Else is_file_included dFile 1
   177    End
   178    else indicate FOUND as (file# = dFile OR file# = 0) // new change
   179    // Flag is used to figure if item_changed_state should be ignored.
   180    // to override the file param.
   181    Move (found) to OK
   182    If Ok Begin
   183       // If flag<>do it always and no change we normally do not update.
   184       // However, if this is a new record we will move it
   185       if ( Flag<>1 and changed_State(self)=0) Begin
   186          Get_Attribute DF_FILE_STATUS of dfile to iStat
   187          If (iStat<>DF_FILE_INACTIVE) Move 0 to Ok // old record...not ok
   188       End
   189       if Ok ;
   190          Send Write_Data
   191    End
   192  end_procedure
   193
   194  // the read_data-message is sent when displaying
   195  // a record (Entry_Display)
   196  //
   197  { Visibility=Private }
   198  Procedure Read_Data
   199    String fieldvalue
   200    Integer dFile dField
   201    get Data_File  to dFile
   202    get Data_Field to dField
   203    If (dFile and dField) Begin
   204       Get_Field_Value dFile dField to fieldValue
   205       Set Bitmap TO (trim(FieldValue))
   206    End
   207  end_procedure
   208
   209  // the clear_data-message is sent when attempting
   210  // to clear the screen
   211
   212  { Visibility=Private }
   213  Procedure Clear_Data
   214    Set Bitmap to ""
   215  end_procedure
   216
   217  // the write_data-message is sent when saving
   218  // a record (Entry_Update)
   219
   220  { Visibility=Private }
   221  Procedure Write_Data
   222    string fname
   223    Integer dFile dField
   224    Get Data_File  to dFile
   225    Get Data_Field to dField
   226    If (dFile AND dField) Begin
   227       Get Bitmap TO fname
   228       If Not (Store_With_Pathname_State(self)) BEGIN
   229          While (Pos("\",Fname))
   230            Mid Fname to Fname  (Length(Fname)) (pos("\",Fname)+1)
   231          End
   232       End
   233       Set_Field_Value dFile dField to FName
   234    End
   235  End_procedure
   236
   237
   238  { Visibility=Private }
   239  Procedure Bind_Data integer File# Integer Field#
   240      Set Data_File  to File#
   241      Set Data_Field to Field#
   242  End_Procedure // Bind_Data
   243
   244  { MethodType=Property }
   245  Function Data_File Integer Itm# returns Integer
   246     function_return (Private.Data_File(self))
   247  End_Function
   248
   249  { MethodType=Property }
   250  Procedure Set Data_File integer item# integer File#
   251    Set Private.Data_File to File#
   252  End_procedure
   253
   254  { MethodType=Property }
   255  Function Data_Field Integer Itm# returns Integer
   256     function_return (Private.Data_Field(self))
   257  End_Function
   258
   259  { MethodType=Property }
   260  Procedure Set Data_Field integer item# integer Field#
   261    Set Private.Data_Field to Field#
   262  End_procedure
   263
   264  { MethodType=Event Visibility=Private }
   265  procedure Refresh integer notifyMode
   266    if notifymode eq MODE_CLEAR_ALL send Entry_Clear_All 1
   267    else Begin
   268      send Entry_Clear 1
   269      send Entry_Display 0 0
   270    end
   271  end_procedure
   272
   273  { Visibility=Private }
   274  procedure Update_Dependent_Items
   275  end_procedure
   276
   277  { Visibility=Private }
   278  function Item_Count returns integer
   279    function_return 1  //pretend to be a single item
   280  end_function
   281End_Class
   282
   283
   284