⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wwprpedt.pas

📁 胜天进销存源码,国产优秀的进销存
💻 PAS
📖 第 1 页 / 共 3 页
字号:
unit Wwprpedt;
{
//
// Components : Property Editors
//
// Copyright (c) 1995-2001 by Woll2Woll Software
//
// 3/5/98 - GetComponentData work generically with TDataSet
// 12/1/98 - Check if grid.datasource.dataset is nil
// 11/19/99 - Fix bug in not updating maplist property
}
interface

{$i wwIfDef.pas}

Uses controls, dialogs, wwDBLook, classes, db, wwTable, wwDBGrid,wwdbigrd,
     wwCommon, wwidlg, dbtables, sysutils, wwselfld, wwstr, wwQuery, wwQBE,
     stdctrls, wwdatainspector, ipabout, registry, wwrgxed2,
     wwricheditbar,
       {$ifdef wwdelphi6up}
       designintf, designeditors,
       {$else}
       dsgnintf,
       {$endif}

{$ifdef win32}
     comctrls, wwrich, wwriched,
{$else}
     LibMain,
{$endif}
     wwlocate, wwfltfld, wwfltdlg, wwrcdvw, wwrcdpnl, buttons, wwintl;


Type

  TwwComponentEditor = class(TDefaultEditor)
  private
    procedure ShowAboutBox;
  public
    function GetVerbCount: Integer; override;
    function GetVerb(Index: Integer): string; override;
    procedure ExecuteVerb(Index: Integer); override;
  end;

  TwwGridComponentEditor = class(TwwComponentEditor)
  private
    function SupportIniSave: boolean;
  public
    function GetVerbCount: Integer; override;
    function GetVerb(Index: Integer): string; override;
    procedure ExecuteVerb(Index: Integer); override;
  end;

  TwwIndexDefsProperty = class(TStringProperty)
     function GetAttributes: TPropertyAttributes; override;
     function GetValue: string; override;
  end;

  TwwControllerListProperty = class(TStringProperty)
     function GetAttributes: TPropertyAttributes; override;
     function GetValue: string; override;
  end;

  TwwTableProperty = class(TComponentProperty)
     procedure GetValues(Proc : TGetStrProc); override;
  end;

  TwwIndexFieldProperty = class(TStringProperty)
     function GetAttributes: TPropertyAttributes; override;
     procedure GetValues(Proc : TGetStrProc); override;
  end;

  TwwSearchFieldProperty = class(TStringProperty)
     function GetAttributes: TPropertyAttributes; override;
     procedure GetValues(Proc : TGetStrProc); override;
  end;

  TwwDBLookupDisplayProperty = class(TPropertyEditor)
     procedure Edit; override;
     function GetAttributes: TPropertyAttributes; override;
     function GetValue: string; override;
  end;

  TwwTableDisplayProperty = class(TPropertyEditor)
     procedure Edit; override;
     function GetAttributes: TPropertyAttributes; override;
     function GetValue: string; override;
  end;

  TwwDBLookupDisplayComponentEditor = class(TwwComponentEditor)
     procedure Edit; override;
  end;

  TSelectedFieldsProperty = class(TPropertyEditor)
    procedure Edit; override;
    function GetAttributes: TPropertyAttributes; override;
    function GetValue: string; override;
  end;

  TwwDBGridComponentEditor = class(TwwGridComponentEditor)
    procedure Edit; override;
  end;

  TwwRecordViewPanelComponentEditor = class(TwwComponentEditor)
    procedure Edit; override;
  end;

  TwwFilterFieldsProperty = class(TPropertyEditor)
     procedure Edit; override;
     function GetAttributes: TPropertyAttributes; override;
     function GetValue: string; override;
  end;

  TwwComboItemsProperty = class(TPropertyEditor)
     procedure Edit; override;
     function GetAttributes: TPropertyAttributes; override;
     function GetValue: string; override;
  end;

  TwwObjPictureProperty = class(TClassProperty)
     procedure Edit; override;
     function GetAttributes: TPropertyAttributes; override;
     function GetValue: string; override;
  end;


  TwwMultiLineStringProperty = class(TClassProperty)
     procedure Edit; override;
     function GetAttributes: TPropertyAttributes; override;
     function GetValue: string; override;
     procedure SetValue(const value: string); override;
  end;

  TwwPictureProperty = class(TClassProperty)
     procedure Edit; override;
     function GetAttributes: TPropertyAttributes; override;
     function GetValue: string; override;
  end;

  TwwPicturePropertyGen = class(TClassProperty)
     procedure Edit; override;
     function GetAttributes: TPropertyAttributes; override;
     function GetValue: string; override;
  end;

  TwwRegexProperty = class(TClassProperty)
     procedure Edit; override;
     function GetAttributes: TPropertyAttributes; override;
     function GetValue: string; override;
  end;

  TwwRecordViewComponentEditor = class(TwwComponentEditor)
    procedure Edit; override;
  end;

{  TwwDataInspectorComponentEditor = class(TDefaultEditor)
    procedure Edit; override;
  end;
}
  TwwGridIndicatorProperty = class(TPropertyEditor)
     procedure Edit; override;
     function GetAttributes: TPropertyAttributes; override;
     function GetValue: string; override;
  end;

{$ifdef win32}
  TwwRichEditItemsProperty = class(TPropertyEditor)
     procedure Edit; override;
     function GetAttributes: TPropertyAttributes; override;
     function GetValue: string; override;
  end;

  TwwRichEditComponentEditor = class(TwwComponentEditor)
     procedure Edit; override;
  end;

  TwwRichEditBarComponentEditor = class(TwwComponentEditor)
     procedure Edit; override;
  end;

{$endif}

function EditSelectedFieldsProperty(AComponent: TComponent;
        listHandle: TStrings; dataSet: TDataSet;
        designer:
        {$ifdef wwDelphi6Up}
        IDesigner;
        {$else}
          {$ifdef wwDelphi4Up}
          IFormDesigner;
          {$else}
          TFormDesigner;
          {$endif}
        {$endif}
        readFromTableComponent: Boolean;
        var useTFields: boolean; propertyType: TwwSelectedPropertyType): boolean;

procedure Register;


implementation

uses wwdbcomb, wwprpcom, wwdbedit, wwprppic, wwpiced2,
     forms, wwstorep, typinfo;

{type SmallString = string[64];}

procedure GetComponentData(AComponent: TComponent;
            var ASelected: TStrings; var ADataSet: TDataSet);
begin
    if AComponent is TwwDBLookupList then begin
       ASelected:= (AComponent as TwwDBLookupList).Selected;
       ADataSet:= (AComponent as TwwDBLookupList).LookupTable;
    end
    else if AComponent is TwwDBCustomLookupCombo then begin
       ASelected:= (AComponent as TwwDBCustomLookupCombo).Selected;
       ADataSet:= (AComponent as TwwDBCustomLookupCombo).LookupTable;
    end
    else if AComponent is TwwLookupDialog then begin
       ASelected:= (AComponent as TwwLookupDialog).Selected;
       ADataSet:= (AComponent as TwwLookupDialog).LookupTable;
    end
    else if AComponent is TwwSearchDialog then begin
       ASelected:= (AComponent as TwwSearchDialog).Selected;
       ADataSet:= (AComponent as TwwSearchDialog).ShadowSearchTable;
    end
    else if AComponent is TwwRecordViewDialog then begin {5/2/97}
       ASelected:= (AComponent as TwwRecordViewDialog).Selected;
       if (AComponent as TwwRecordViewDialog).DataSource<>nil then
          ADataSet:= (AComponent as TwwRecordViewDialog).DataSource.Dataset
       else ADataSet:= nil;
    end
    else if AComponent is TwwRecordViewPanel then begin {5/2/97}
       ASelected:= (AComponent as TwwRecordViewPanel).Selected;
       if (AComponent as TwwRecordViewPanel).DataSource<>nil then
          ADataSet:= (AComponent as TwwRecordViewPanel).DataSource.Dataset
       else ADataSet:= nil;
    end
{    else if AComponent is TwwDataInspector then begin
       ASelected:= (AComponent as TwwDataInspector).Selected;
       if (AComponent as TwwDataInspector).DataSource<>nil then
          ADataSet:= (AComponent as TwwDataInspector).DataSource.Dataset
       else ADataSet:= nil;
    end}
    else ADataset:= AComponent as TDataset;
{
    if AComponent is TwwTable then begin
       ADataSet:= AComponent as TwwTable
    end
    else if AComponent is TwwQuery then begin
       ADataSet:= AComponent as TwwQuery
    end
    else if AComponent is TwwQBE then begin
       ADataSet:= AComponent as TwwQBE
    end
    else if AComponent is TwwStoredProc then begin
       ADataSet:= AComponent as TwwStoredProc
    end
}
end;


{*** Property editors ***}
Function TwwGridIndicatorProperty.GetValue: string;
begin
   result:= '<TSpeedButton>'
end;

function TwwGridIndicatorProperty.GetAttributes: TPropertyAttributes;
begin
   result:= [paDialog];
end;

procedure TwwGridIndicatorProperty.Edit;
var grid: TwwDBGrid;
begin
   grid:= GetComponent(0) as TwwDBGrid;
   if grid.IndicatorButton=nil then
   begin
      grid.IndicatorButton:= TwwIButton.create(wwGetOwnerForm(grid));
      grid.IndicatorButton.parent:= grid;
      grid.IndicatorButton.name:= grid.name + 'IButton';
      grid.IndicatorButton.width:= 13;
      grid.IndicatorButton.AllowAllUp:=True;
   end;
  {$ifdef win32}
   Designer.SelectComponent(grid.IndicatorButton);
  {$else}
   Complib.GetActiveForm.SetSelection((GetComponent(0) as TwwDBGrid).IndicatorButton.Name);
  {$endif}
end;

function TwwTableDisplayProperty.GetValue: string;
begin
   result:= '<Display>';
end;

function TwwTableDisplayProperty.GetAttributes: TPropertyAttributes;
begin
   result:= [paDialog];
end;

{ Define selected fields property editor for grid }
function EditSelectedFieldsProperty(AComponent: TComponent;
        listHandle: TStrings; dataSet: TDataSet;
        designer:
        {$ifdef wwDelphi6Up}
        IDesigner;
        {$else}
          {$ifdef wwDelphi4Up}
          IFormDesigner;
          {$else}
          TFormDesigner;
          {$endif}
        {$endif}
//         {$ifdef wwDelphi4Up}IFormDesigner{$else}TFormDesigner{$endif};
        readFromTableComponent: Boolean;
        var useTFields: boolean; propertyType: TwwSelectedPropertyType): boolean;
var
  i,j: integer;
  apos: integer;
  SaveList: TStrings;
  ReadOnlyStr, GroupStr: string;
begin
  result:= False;
  if ReadFromTableComponent and (useTFields or (listhandle.count=0)) then begin
       SaveList:= TStringlist.create;
       SaveList.assign(ListHandle);
       ListHandle.clear;
       with dataSet do begin
          if (not Active) and (FieldCount=0) then begin
             MessageDlg('DataSet for this component must be active or have persistent fields to edit design.', mtInformation, [mbok], 0);
             exit;
          end;

          for i:= 0 to fieldCount-1 do begin
             if (fields[i].visible) then begin

                for j:= 0 to SaveList.count-1 do
                begin
                    apos:= 1;
                    ReadOnlyStr:= 'F';
                    GroupStr:= '';
                    if Fields[i].FieldName=strGetToken(SaveList[j], #9, apos) then
                    begin
                        strGetToken(SaveList[j], #9, apos); // display width
                        strGetToken(SaveList[j], #9, apos); // display label
                        ReadOnlyStr:= strGetToken(SaveList[j], #9, apos);
                        GroupStr:= strGetToken(SaveList[j], #9, apos);
                        break;
                    end;
                end;

                if propertyType = sptObjectViewType then
                   ListHandle.add(fields[i].fieldName + #9 +  '0' + #9 +
                              fields[i].displayLabel + #9 + 'F')
                else
                   ListHandle.add(fields[i].fieldName + #9 +
                              inttostr(fields[i].displayWidth) + #9 +
                              fields[i].displayLabel + #9 + ReadOnlyStr + #9 + GroupStr);
             end
          end;
       end;

       SaveList.Free;
   end;

   if wwSelectTableFields(AComponent, dataSet, listHandle, useTFields, Designer, propertyType) then
   begin
      if Designer<>Nil then Designer.modified;
      wwDataModuleChanged(Dataset);
      if (dataSet is TwwTable) then
         if (TwwTable(dataset).query.count=0) then dataSet.refresh;
{               dataset.resync([]);}
      result:= True;
   end
end;


procedure TwwTableDisplayProperty.Edit;
var
   listHandle : TStrings;
   dataSet: TDataSet;
   useTFields: boolean;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -