wwrcdpnl.pas
来自「infopower 4000 for delphi 2006」· PAS 代码 · 共 1,684 行 · 第 1/5 页
PAS
1,684 行
procedure TwwRecordViewPanel.DoOnAfterCreateControl(
Sender: TObject; curField: TField; Control: TControl);
var ButtonEffects: TwwButtonEffects;
Frame: TwwEditFrame;
// OldHeight: integer;
procedure UpdatePositions;
begin
if (style=rvpshorizontal) then begin
if (Control is TwwRadioGroup) and TwwRadioGroup(Control).ShowGroupCaption then
begin
curLabel.visible:= False;
control.top:= curlabel.top;
TwwRadioGroup(control).caption:= curlabel.caption;
end;
if (rvopLabelsBeneathControl in Options) then
begin
if not (control is TLabel) then
begin
control.top:= curLabel.Top;
curLabel.Top:=
control.top + control.Height + EditSpacing.HorizontalView.BetweenLabelEdit-1;
end
end;
end;
{
if (rvopLabelsBeneathControl in Options) and (style=rvpsHorizontal) then
begin
if not (control is TLabel) then
begin
control.top:= curLabel.Top;
curLabel.Top:=
control.top + control.Height + EditSpacing.HorizontalView.BetweenLabelEdit-1;
end
end;
}
end;
begin
ButtonEffects:= TwwButtonEffects.Get(Control);
Frame:= TwwEditFrame.Get(Control);
if ButtonEffects<>nil then with buttoneffects do begin
transparent:= rvcTransparentButtons in ControlOptions;
flat:= rvcFlatButtons in ControlOptions;
end;
if Frame<>nil then Frame.Assign(EditFrame);
try
if (Frame<>nil) then
DoSetControlEffects(Sender, curfield, control, Frame, ButtonEffects);
// OldHeight:= Control.Height;
if Assigned(FOnAfterCreateControl) then
FOnAfterCreateControl(Sender, curfield, control);
{if Control.Height<>OldHeight then }
UpdatePositions;
finally
end;
end;
procedure TwwRecordViewPanel.DoOnBeforeCreateControl(
Sender: TObject; curField: TField; var accept: boolean);
begin
if Assigned(FOnBeforeCreateControl) then
FOnBeforeCreateControl(Sender, curfield, accept);
end;
procedure TwwRecordViewPanel.FreeNonCustomControls(DestroyControls: boolean);
var i, j: integer;
DeleteControl: boolean;
customItem: TwwCustomControlItem;
begin
for i:= ControlCount-1 downto 0 do begin
DeleteControl:= True;
if Controls[i].owner<>self then DeleteControl:= False;
for j:= 0 to CustomControlList.count-1 do begin
customItem:= TwwCustomControlItem(CustomControlList[j]);
if Controls[i]=CustomItem.control then
begin
DeleteControl:= False;
if (Controls[i].Owner is TWinControl) then
begin
Controls[i].visible:= CustomItem.Oldvisible;
Controls[i].left:= CustomItem.left;
Controls[i].top:= CustomItem.top;
Controls[i].width:= CustomItem.width;
Controls[i].height:= CustomItem.height;
wwSetControlDataSource(TWinControl(Controls[i]), nil);
wwSetControlDataField(TWinControl(Controls[i]), '');
if HasButtonEffects(TWinControl(Controls[i])) then
begin
TwwButtonEffects.Get(Controls[i]).Transparent:= customItem.ButtonTransparent;
TwwButtonEffects.Get(Controls[i]).Flat:= customItem.ButtonFlat;
end;
if (CustomItem.OldParent=Nil) or { 10/1/98 }
not (csDestroying in CustomItem.OldParent.ComponentState) then
Controls[i].parent:= CustomItem.OldParent //ValidParentForm(self)
end;
break;
end
end;
if DeleteControl then begin
if DestroyControls then Controls[i].Free
else begin
if Controls[i] is TWinControl then
begin
if not wwSetControlDataField(controls[i] as TWinControl, '') then continue;
end
end
end
end;
for i:= 0 to CustomControlList.count-1 do TwwCustomControlItem(CustomControlList[i]).Free;
CustomControlList.Clear;
end;
Function TwwRecordViewPanel.UseCustomControls: boolean;
begin
result:= (rvopUseCustomControls in Options)
{ and
not (csDesigning in ComponentState)}
end;
procedure TwwRecordViewPanel.AddControlPosition(Control: TControl; Left, Top, Width, Height: integer);
var cp: TControlPosition;
begin
cp:= TControlPosition.create;
cp.Control:= Control;
cp.Left:= Left;
cp.Top:= Top;
cp.Height:= Height;
cp.Width:= Width;
ControlPositions.Add(cp);
end;
Procedure TwwRecordViewPanel.DisplayVertical(Recreate: boolean);
const FixedEditWidthConst=0;
var
LabelWidth, MaxLabelWidth, MaxEditWidth: integer;
APos, i, j, numFields: integer;
curFieldDisplayWidth: integer;
curFieldDisplayLabel: wwSmallString;
curFieldReadOnly: boolean;
curField: TField;
curLabel: Tlabel;
customEdit: TWinControl;
checkbox: TwwDBCheckBox;
EditHeight: integer;
FixedEditWidth: integer;
accept: boolean;
PrevTop: integer;
checkboxOn, checkboxOff: wwSmallString;
Bitmap: TBitmap;
curEditControl: TControl;
NextTabOrder: integer;
tempWidth: integer;
tempControlCount: integer;
ControlPositionLeft, ControlPositionTop,
ControlPositionWidth, ControlPositionHeight: integer;
cp: TControlPosition;
EditControl: TWinControl;
ShowingVertScrollBar: boolean;
OldWidth: integer;
BackgroundImage: boolean;
Function CreateEditControl(EditControl: TWinControl): boolean;
var
tempMask: string;
tempAutoFill: boolean;
tempUsePictureMask: boolean;
begin
result:= False;
if EditControl is TwwDBCustomEdit then
begin
if wwGetPictureControl(self)=self then { Picture masks do not come from dataset }
begin
wwPictureByField(self, curField.FieldName, False,
tempMask, tempAutoFill, tempUsePictureMask);
with TwwDBEdit(EditControl).Picture do
begin
PictureMaskFromDataSet:= False;
PictureMask:= tempMask;
AutoFill:=tempAutoFill;
end
end
end;
with EditControl do begin
if recreate then begin
curLabel.FocusControl:= EditControl;
visible:= False;
parent:= self;
if not wwSetControlDataSource(EditControl, self.datasource) then exit;
if not wwSetControlDataField(EditControl, curField.fieldName) then exit;
if curFieldReadonly or curField.calculated then
begin
TEdit(EditControl).color:= ReadOnlyColor;
EditControl.tabStop:= False;
end;
if EditControl is TwwDBEdit then
begin
if curField is TStringField then {7/29/97 - Limit length to field size }
if curField.editmask='' then // 9/9/02
TEdit(EditControl).maxlength:= curField.Size;
end;
end;
if isSingleLineEditControl(EditControl) then
TempWidth:= (curFieldDisplayWidth+1) * Bitmap.Canvas.TextWidth('0') + 3
else
TempWidth:= FixedEditWidth; //Self.width - EditStartOffset - Margin.RightOffset;
if EditControl is TwwDBDateTimePicker then
begin
TempWidth:=
TempWidth + TwwDBDateTimePicker(EditControl).Button.Width
end;
if rvopShortenEditBox in Options then begin
if TempWidth>FixedEditWidth then TempWidth:= FixedEditWidth;
end;
if rvopConsistentEditWidth in Options then begin
if TempWidth<FixedEditWidth then TempWidth:= FixedEditWidth;
end;
ControlPositionLeft:= EditStartOffset; {EditPosition.LeftOffset + LabelWidth + 5;}
ControlPositionTop:= PrevTop;
if IsSingleLineEditControl(EditControl) then
ControlPositionHeight:= EditControl.Height
else
ControlPositionHeight:= Bitmap.Canvas.TextHeight('0') * LinesPerMemoControl + 8; {2 lines of Memo}
{ 11/11/99 - Only set enabled to false if recreating control }
if Recreate and CurFieldReadOnly then enabled:=False;
end;
if not Recreate then begin
if rvopShortenEditBox in Options then begin
if TempWidth>FixedEditWidth then TempWidth:= FixedEditWidth;
end;
if rvopConsistentEditWidth in Options then begin
if TempWidth<FixedEditWidth then TempWidth:= FixedEditWidth; //!!!
end;
ControlPositionWidth:= TempWidth;
ControlPositionHeight:= EditControl.Height;
AddControlPosition(EditControl, ControlPositionLeft, ControlPositionTop,
ControlPositionWidth, ControlPositionHeight);
end
else begin
EditControl.Left:= ControlPositionLeft;
EditControl.Top:= ControlPositionTop;
EditControl.Height:= ControlPositionHeight;
OldWidth:= EditControl.Width; { 10/22/98 - Respect width change }
DoOnAfterCreateControl(self, curField, EditControl);
if EditControl.Width<>OldWidth then TempWidth:= EditControl.Width; { 10/22/98 }
if rvopShortenEditBox in Options then begin
if TempWidth>FixedEditWidth then TempWidth:= FixedEditWidth;
end;
if rvopConsistentEditWidth in Options then begin
if TempWidth<FixedEditWidth then TempWidth:= FixedEditWidth; //!!
end;
EditControl.Width:= TempWidth;
end;
MaxEditWidth:= wwmax(MaxEditWidth, TempWidth);
PrevTop:= Prevtop + EditControl.Height + EditSpacing.VerticalView.BetweenRow;
EditHeight := EditControl.Height;
EditControl.tabOrder:= NextTabOrder; {9/3/98 - Fix tab order problem }
inc(NextTabOrder);
result:= True;
if recreate then curField.FreeNotification(self);
end;
begin
tempControlCount:= 0;
for i:= 0 to ControlCount-1 do
if Controls[i].owner=self then inc(TempControlCount);
if TempControlCount=0 then Recreate:= True;
if FDataLink.Active or (DataSource=Nil) or (Datasource.dataset=Nil) then
begin
if (Recreate) then FreeNonCustomControls(True);
if (DataSource=nil) or (Datasource.dataset=nil) or (not Datasource.dataset.active) then begin
exit;
end
end
else begin
// if (Recreate) then FreeNonCustomControls; { If inactive then don't show controls }
exit;
end;
PrevTop:= Margin.TopOffset;
if (selected.count=0) then numFields:= DataSource.DataSet.FieldCount
else numFields:= Selected.count;
Bitmap:= TBitmap.create;
ControlPositions.Clear;
try
MaxLabelWidth:= 0;
Bitmap.Canvas.Font := LabelFont;
for i:= 0 to numFields-1 do begin
if (Selected.count=0) or FuseTFields then begin
curField:= DataSource.dataset.fields[i];
curFieldDisplayLabel:= curField.DisplayLabel;
curFieldReadOnly:= curfield.ReadOnly;
end
else begin
APos:= 1;
curField:= DAtaSource.dataset.findField(strGetToken(Selected[i], #9, APos));
if curfield<>nil then begin
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?