📄 wwrcdpnl.pas
字号:
if (Patch[0]=True) and curFieldReadOnly then
begin
CustomEdit.tabStop:= not curFieldReadOnly;
CustomEdit.enabled:= not curFieldReadOnly;
TEdit(CustomEdit).Color:= ReadOnlyColor;
end;
DoOnAfterCreateControl(self, curField, CustomEdit);
if CustomEdit.Width<>OldWidth then TempWidth:= CustomEdit.Width; { 10/22/98 }
customEdit.Width:= TempWidth;
end;
MaxEditWidth:= wwmax(MaxEditWidth, TempWidth);
PrevTop:= Prevtop + customEdit.Height + EditSpacing.VerticalView.BetweenRow;
EditHeight:= customEdit.Height;
tabOrder:= NextTabOrder;
inc(NextTabOrder);
end
else if (curField is TDateTimeField) and
(rvopUseDateTimePicker in Options) then
begin
if recreate or (curEditControl=Nil) then
EditControl:= TwwDBDateTimePicker.create(self)
else EditControl:= TwwDBDateTimePicker(curEditControl);
if not CreateEditControl(EditControl) then continue;
end
else if (not (csDesigning in ComponentState)) and
wwIsRichEditField(curField, True) then begin
if recreate or (curEditControl=Nil) then EditControl:= TwwDBRichEdit.create(self)
else EditControl:= TwwDBRichEdit(curEditControl);
if not CreateEditControl(EditControl) then continue;
end
else if (curField.dataType = ftMemo) then begin
if recreate or (curEditControl=Nil) then
begin
if EditFrame.IsFrameEffective then
EditControl:= TwwDBEditMemo.create(self)
else
// EditControl:= TwwDBMemo.create(self)
EditControl:= TwwDBEditMemo.create(self)
end
else EditControl:= TWinControl(curEditControl);
if not CreateEditControl(EditControl) then continue;
end
else if (curField.dataType = ftGraphic) then begin { 8/27/98 - Support images }
if recreate or (curEditControl=Nil) then editControl:= TDBImage.create(self)
else EditControl:= TWinControl(curEditControl);
if not CreateEditControl(EditControl) then continue;
end
else begin
if recreate or (curEditControl=Nil) then begin
EditControl:= CreateDefaultEditControl(self);
// EditControl:= TwwDBEdit.create(self);
EditControl.controlStyle:= EditControl.ControlStyle + [csNoDesignVisible];
end
else EditControl:= TWinControl(curEditControl);
if not CreateEditControl(EditControl) then continue;
end
end;
PrevTop := PrevTop + Margin.BottomOffset - EditSpacing.VerticalView.BetweenRow;
VertScrollBar.Margin:= 6;
VertScrollBar.Increment:= EditHeight + EditSpacing.VerticalView.BetweenRow;
VertScrollBar.Range := PrevTop;
{ Shrink edit controls to fit panel width }
if (Height<PrevTop) then
begin
{$ifdef wwDelphi4up}
ShowingVertScrollBar:= True;
{$else}
ShowingVertScrollBar:= False; { Skip Delphi 4 specific code for setting horz scroll range }
{$endif}
FixedEditWidth:= FixedEditWidth - GetSystemMetrics(SM_CXHThumb);
if Recreate then begin
for j:= 0 to ControlCount-1 do begin
if TControl(Controls[j]) is TWinControl then begin
curEditControl:= Controls[j];
if ((rvopShortenEditBox in Options) or
(rvopConsistentEditWidth in Options) or
(not isSingleLineEditControl(TWinControl(curEditControl)))) then
if (curEditControl.Width>FixedEditWidth) then
begin
curEditControl.Width:= FixedEditWidth;
end
end;
end
end
else begin
for j:= 0 to ControlPositions.count-1 do
begin
cp:= TControlPosition(ControlPositions[j]);
with cp do
begin
if Control is TWinControl then
begin
if ((rvopShortenEditBox in Options) or
(rvopConsistentEditWidth in Options) or
(not isSingleLineEditControl(TWinControl(Control)))) then
if (Width>FixedEditWidth) then
begin
Width:= FixedEditWidth;
end;
end
end
end
end;
if ((rvopShortenEditBox in Options) or
(rvopConsistentEditWidth in Options)) then
MaxEditWidth:= wwMin(MaxEditWidth, FixedEditWidth)
else begin
MaxEditWidth:= 0;
for j:= 0 to ControlPositions.count-1 do
begin
cp:= TControlPosition(ControlPositions[j]);
MaxEditWidth:= wwMax(MaxEditWidth, cp.width);
end
end
end
else ShowingVertScrollBar:= False;
HorzScrollBar.Margin:= 6;
if (rvopConsistentEditWidth in Options) then
HorzScrollBar.Range := MaxEditWidth
else begin
HorzScrollBar.Range :=
EditStartOffset + MaxEditWidth + Margin.RightOffset;
if ShowingVertScrollBar then
HorzScrollBar.Range:=
HorzScrollBar.Range - GetSystemMetrics(SM_CXHThumb);
end;
for i:= 0 to ControlPositions.count-1 do
begin
cp:= TControlPosition(ControlPositions[i]);
with cp do
begin
if (Control is TWinControl) then
SetWindowPos ((control as TWinControl).Handle, 0,
left, top, width, height, SWP_NOACTIVATE)
else
control.SetBounds(left, top, width, height);
end
end;
BackgroundImage:= False; // 8/7/00
for i:= 0 to ControlCount-1 do
begin
if (Controls[i] is TGraphicControl) and
not (Controls[i] is TLabel) then
begin
BackgroundImage:=True;
end
end;
for i:= 0 to ControlCount-1 do
begin
Controls[i].visible:= True;
if Patch[1] and EditFrame.enabled and EditFrame.Transparent and BackgroundImage then
Update; // 8/6/00 - Need to complete imager painting if present
end;
{ Set focus to first wincontrol }
{ if Focused and Recreate then
begin
for i:= 0 to ControlCount-1 do
begin
if Controls[i] is TWinControl then
begin
TWinControl(Controls[i]).setFocus;
break;
end
end;
end
}
finally
Bitmap.Free;
for i:= 0 to ControlPositions.count-1 do TControlPosition(ControlPositions[i]).Free;
ControlPositions.Clear;
end;
end;
function TwwRecordViewPanel.IsSingleLineEditControl(EditControl: TWinControl): boolean;
begin
result:= ((EditControl is TwwDBEdit) or (EditControl is TwwDBDateTimePicker));
end;
Procedure TwwRecordViewPanel.DisplayHorizontal(Recreate: boolean);
const FixedEditWidthConst=0;
var
OrigMaxEditWidth, MaxEditWidth: integer;
APos, i, j, numFields: integer;
curFieldDisplayWidth: integer;
curFieldEditWidth: integer;
curFieldLabelWidth: integer;
curFieldDisplayLabel: wwSmallString;
curFieldReadOnly: boolean;
RealMaxLineWidth, MaxLineWidth,curLineWidth: integer;
LastEditHeight:integer;
LastLabelHeight:integer;
curField: TField;
curLabel: Tlabel;
customEdit: TWinControl;
wwDbEdit: TwwDBEdit;
checkbox: TwwDBCheckBox;
FixedEditWidth: integer;
accept: boolean;
PrevTop: integer;
checkboxOn, checkboxOff: wwSmallString;
Bitmap: TBitmap;
curEditControl: TControl;
NextTabOrder: integer;
TempWidth: integer;
TempControlCount: integer;
PanelWidth: integer;
ControlPositionLeft, ControlPositionTop,
ControlPositionWidth, ControlPositionHeight: integer;
cp: TControlPosition;
EditControl: TWinControl;
ShowingVertScrollBar: boolean;
OldWidth: integer;
BackgroundImage: boolean;
Function GetControlPosition(control: TControl): TControlPosition;
var i: integer;
begin
result:= nil;
for i:= 0 to ControlPositions.count-1 do
if TControlPosition(ControlPositions[i]).Control=control then
result:= TControlPosition(ControlPositions[i]);
end;
procedure UpdateTopPosition(Height: integer; var TopPosition: integer);
begin
if (rvopLabelsBeneathControl in Options) and (style=rvpsHorizontal) then
begin
TopPosition:= GetControlPosition(curLabel).Top;
GetControlPosition(curLabel).Top:=
TopPosition + Height + EditSpacing.HorizontalView.BetweenLabelEdit-1;
end
end;
Function CreateEditControl(EditControl: TWinControl): boolean;
var
tempMask: string;
tempAutoFill: boolean;
tempUsePictureMask: boolean;
begin
result:= False;
{ 1/5/2000 - Fix bug with picture masks for non wwdatasets }
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;
ControlPositionleft:= EditStartOffset+curLineWidth;
ControlPositiontop:= PrevTop+EditSpacing.HorizontalView.BetweenLabelEdit+curlabel.Height;
TempWidth:= (curFieldDisplayWidth+1) * Bitmap.Canvas.TextWidth('0') + 3;
if EditControl is TwwDBDateTimePicker then
begin
TempWidth:=
TempWidth + TwwDBDateTimePicker(EditControl).Button.Width
end;
if not IsSingleLineEditControl(EditControl) then
begin
if (rvopMaximizeMemoWidth in Options) then begin
ControlPositionleft:= EditStartOffset;
ControlPositionTop:= PrevTop+EditSpacing.HorizontalView.BetweenLabelEdit+curlabel.Height;
TempWidth:= wwMax(OrigMaxEditWidth, FixedEditWidth);
end
end;
if (rvopShortenEditBox in Options) and (TempWidth>FixedEditWidth) then
TempWidth:= FixedEditWidth;
if IsSingleLineEditControl(EditControl) then
ControlPositionHeight:= EditControl.Height
else
ControlPositionHeight:= Bitmap.Canvas.TextHeight('0') * LinesPerMemoControl + 8; {2 lines of Memo}
if Recreate and CurFieldReadOnly then enabled:=False;
end;
if not Recreate then begin
ControlPositionWidth:= TempWidth;
ControlPositionHeight:= EditControl.Height;
UpdateTopPosition(ControlPositionHeight, ControlPositionTop);
AddControlPosition(EditControl, ControlPositionLeft, ControlPositionTop,
ControlPositionWidth, ControlPositionHeight);
end
else begin
EditControl.Left:= ControlPositionLeft;
EditControl.Top:= ControlPositionTop;
EditControl.Height:= ControlPositionHeight;
OldWidth:= EditControl.Width; { 10/22/98 }
DoOnAfterCreateControl(self, curField, EditControl);
if EditControl.Width<>OldWidth then { 10/22/98 }
TempWidth:= EditControl.Width;
if (rvopShortenEditBox in Options) and (TempWidth>FixedEditWidth) then
TempWidth:= FixedEditWidth;
EditControl.Width:= TempWidth;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -