📄 eermodel.pas
字号:
begin
if(hscW>0)then
TForm(parent).HorzScrollBar.Position:=
Round(hsc*(TForm(parent).HorzScrollBar.Range/hscW))-
Round((TForm(parent).Width/2 - ((TForm(parent).Width /2)*(TForm(parent).HorzScrollBar.Range/hscW))))+
x2scroll;
end
else
begin
Left:=(TForm(parent).Width-Width) div 2;
TForm(parent).Invalidate;
end;
if(Height>=TForm(parent).Height)then
begin
if(hscH>0)then
TForm(parent).VertScrollBar.Position:=
Round(vsc*(TForm(parent).VertScrollBar.Range/hscH))-
Round((TForm(parent).Height/2 - ((TForm(parent).Height /2)*(TForm(parent).VertScrollBar.Range/hscH))))+
y2scroll;
end
else
begin
Top:=(TForm(parent).Height-Height) div 2;
TForm(parent).Invalidate;
end;
//Relation Icon Size
if(DMEER.Notation=noErwin)then
RelIconSize:=EvalZoomFac(9)
else
RelIconSize:=EvalZoomFac(18);
RelIconDSize:=Trunc(RelIconSize/2);
finally
DMEER.DisablePaint:=False;
end;
//Resize GridPaintBox
GridPaintBox.Width:=Width;
GridPaintBox.Height:=Height;
if(Not(DisableModelRefresh))then
begin
Refresh;
DMEER.UpdateStatusBar;
DMEER.RefreshNavPalette;
end;
end;
procedure TEERModel.Refresh;
var i: integer;
begin
if(Not(DisableModelRefresh))then
begin
//Rescale all EER-Objects
for i:=ComponentCount-1 downto 0 do
if(Components[I].Classparent=TEERObj)then
TEERObj(Components[I]).RefreshObj;
Invalidate;
end;
end;
procedure TEERModel.RefreshFont;
var i: integer;
begin
//Set Font for SelectionRect
SelectionRect.Canvas.Font.Name:=DefModelFont;
SelectionRect.ParentFont:=False;
//Set Font for all EER-Objects
for i:=ComponentCount-1 downto 0 do
if(Components[I].Classparent=TEERObj)then
begin
if(Not(Components[I].ClassnameIs('TEERRel')))then
begin
TEERObj(Components[I]).Font.Name:=DefModelFont;
TEERObj(Components[I]).ParentFont:=False;
end
else
begin
TEERRel(Components[I]).ParentFont:=False;
TEERRel(Components[I]).Font.Name:=DefModelFont;
TEERRel(Components[I]).RelCaption.Font.Name:=DefModelFont;
TEERRel(Components[I]).RelCaption.Canvas.Font.Name:=DefModelFont;
TEERRel(Components[I]).RelEndInterval.Font.Name:=DefModelFont;
TEERRel(Components[I]).RelEndInterval.Canvas.Font.Name:=DefModelFont;
TEERRel(Components[I]).RelStartInterval.Font.Name:=DefModelFont;
TEERRel(Components[I]).RelStartInterval.Canvas.Font.Name:=DefModelFont;
end;
end;
end;
procedure TEERModel.RefreshTblImgs;
var thePath: string;
begin
thePath:=ExtractFilePath(Application.ExeName)+
'Gfx'+PathDelim+'Table'+PathDelim;
TblHeaderBmp.LoadFromFile(thePath+'Header_'+DMEER.TblHeaderBGImgs+'.bmp');
TblHeaderRightBmp.LoadFromFile(thePath+'HeaderRight_'+DMEER.TblHeaderBGImgs+'.bmp');
//Linked Header
if(Not(FileExists(thePath+'Header_'+DMEER.TblHeaderBGImgs+'_Linked.bmp')))then
TblHeaderLinkedBmp.LoadFromFile(thePath+'Header_'+DMEER.TblHeaderBGImgs+'.bmp')
else
TblHeaderLinkedBmp.LoadFromFile(thePath+'Header_'+DMEER.TblHeaderBGImgs+'_Linked.bmp');
if(Not(FileExists(thePath+'HeaderRight_'+DMEER.TblHeaderBGImgs+'_Linked.bmp')))then
TblHeaderRightLinkedBmp.LoadFromFile(thePath+'HeaderRight_'+DMEER.TblHeaderBGImgs+'.bmp')
else
TblHeaderRightLinkedBmp.LoadFromFile(thePath+'HeaderRight_'+DMEER.TblHeaderBGImgs+'_Linked.bmp');
Refresh;
end;
function TEERModel.GetZoomFac: double;
begin
GetZoomFac:=ZoomFac;
end;
procedure TEERModel.ZoomIn(x, y: integer);
begin
SetZoomFac(ZoomFac*1.3333333333, x, y);
end;
procedure TEERModel.ZoomOut(x, y: integer);
begin
SetZoomFac(ZoomFac/1.3333333333, x, y);
end;
procedure TEERModel.SetPositionMarker(nr: integer);
begin
if(nr>=0)and(nr<=9)then
begin
TPosMarker(PosMarkers.Items[nr]).ZoomFac:=GetZoomFac;
TPosMarker(PosMarkers.Items[nr]).X:=TForm(parent).HorzScrollBar.Position;
TPosMarker(PosMarkers.Items[nr]).Y:=TForm(parent).VertScrollBar.Position;
end;
end;
procedure TEERModel.GotoPositionMarker(nr: integer);
begin
if(nr>=0)and(nr<=9)then
if(TPosMarker(PosMarkers.Items[nr]).ZoomFac<>-1)then
begin
SetZoomFac(TPosMarker(PosMarkers.Items[nr]).ZoomFac,
TPosMarker(PosMarkers.Items[nr]).X,
TPosMarker(PosMarkers.Items[nr]).Y);
TForm(parent).HorzScrollBar.Position:=TPosMarker(PosMarkers.Items[nr]).X;
TForm(parent).VertScrollBar.Position:=TPosMarker(PosMarkers.Items[nr]).Y;
end;
end;
function TEERModel.GetFontHeight: integer;
var theFontHeight: integer;
begin
theFontHeight:=Round(EvalZoomFac(12)*(72/DPI));
if(theFontHeight<1)then
theFontHeight:=1;
GetFontHeight:=theFontHeight;
end;
function TEERModel.GetTextExtent(s: string): TSize;
var theSize: TSize;
theFontHeight: integer;
reCalc: double;
begin
//Get Font Size
theFontHeight:=Round(EvalZoomFac(12));
//if it would be smaller then 6px, calculate from fixed 6px Font
reCalc:=1;
if(theFontHeight<8)then
begin
reCalc:=12*(ZoomFac/100)/8;
theFontHeight:=8;
end;
SelectionRect.Canvas.Font.Height:=theFontHeight;
theSize:=SelectionRect.Canvas.TextExtent(s);
if(reCalc<>1)then
begin
theSize.cx:=Round(theSize.cx*reCalc);
theSize.cy:=Round(theSize.cy*reCalc);
end;
GetTextExtent:=theSize;
end;
// ---------------------------------------------------
// Functions
procedure TEERModel.AddImgToPopupImgList(fname: string);
var theImg: TBitmap;
begin
theImg:=TBitmap.Create;
theImg.LoadFromFile(fname);
PopUpMenuImgs.Add(theImg, nil);
end;
procedure TEERModel.LoadModelBitmaps;
var
thePath: string;
begin
//Load Table Header Bitmaps
TblHeaderBmp:=TBitmap.Create;
TblHeaderRightBmp:=TBitmap.Create;
TblHeaderLinkedBmp:=TBitmap.Create;
TblHeaderRightLinkedBmp:=TBitmap.Create;
FieldBmp:=TBitmap.Create;
FieldKeyBmp:=TBitmap.Create;
IndexBmp:=TBitmap.Create;
Field_FKBmp:=TBitmap.Create;
Index_FKBmp:=TBitmap.Create;
PopUpMenuImgs:=TImageList.Create(self);
PopUpMenuImgs.Masked:=True;
PopUpMenuImgs.Width:=16;
PopUpMenuImgs.Height:=15;
try
thePath:=ExtractFilePath(Application.ExeName)+
'Gfx'+PathDelim+'Table'+PathDelim;
if(Not(FileExists(thePath+'Header_'+DMEER.TblHeaderBGImgs+'.bmp')))then
raise EInOutError.Create(DMMain.GetTranslatedMessage('File %s not found.', 209,
thePath+'Header_'+DMEER.TblHeaderBGImgs+'.bmp'));
TblHeaderBmp.LoadFromFile(thePath+'Header_'+DMEER.TblHeaderBGImgs+'.bmp');
if(Not(FileExists(thePath+'HeaderRight_'+DMEER.TblHeaderBGImgs+'.bmp')))then
raise EInOutError.Create(DMMain.GetTranslatedMessage('File %s not found.', 209,
thePath+'HeaderRight_'+DMEER.TblHeaderBGImgs+'.bmp'));
TblHeaderRightBmp.LoadFromFile(thePath+'HeaderRight_'+DMEER.TblHeaderBGImgs+'.bmp');
//Linked Header
if(Not(FileExists(thePath+'Header_'+DMEER.TblHeaderBGImgs+'_Linked.bmp')))then
TblHeaderLinkedBmp.LoadFromFile(thePath+'Header_'+DMEER.TblHeaderBGImgs+'.bmp')
else
TblHeaderLinkedBmp.LoadFromFile(thePath+'Header_'+DMEER.TblHeaderBGImgs+'_Linked.bmp');
if(Not(FileExists(thePath+'HeaderRight_'+DMEER.TblHeaderBGImgs+'_Linked.bmp')))then
TblHeaderRightLinkedBmp.LoadFromFile(thePath+'HeaderRight_'+DMEER.TblHeaderBGImgs+'.bmp')
else
TblHeaderRightLinkedBmp.LoadFromFile(thePath+'HeaderRight_'+DMEER.TblHeaderBGImgs+'_Linked.bmp');
if(Not(FileExists(thePath+'Field.bmp')))then
raise EInOutError.Create(DMMain.GetTranslatedMessage('File %s not found.', 209,
thePath+'Field.bmp'));
FieldBmp.LoadFromFile(thePath+'Field.bmp');
if(Not(FileExists(thePath+'FieldKey.bmp')))then
raise EInOutError.Create(DMMain.GetTranslatedMessage('File %s not found.', 209,
thePath+'FieldKey.bmp'));
FieldKeyBmp.LoadFromFile(thePath+'FieldKey.bmp');
if(Not(FileExists(thePath+'Index.bmp')))then
raise EInOutError.Create(DMMain.GetTranslatedMessage('File %s not found.', 209,
thePath+'Index.bmp'));
IndexBmp.LoadFromFile(thePath+'Index.bmp');
if(Not(FileExists(thePath+'Field_FK.bmp')))then
raise EInOutError.Create(DMMain.GetTranslatedMessage('File %s not found.', 209,
thePath+'Field_FK.bmp'));
Field_FKBmp.LoadFromFile(thePath+'Field_FK.bmp');
if(Not(FileExists(thePath+'Index_FK.bmp')))then
raise EInOutError.Create(DMMain.GetTranslatedMessage('File %s not found.', 209,
thePath+'Index_FK.bmp'));
Index_FKBmp.LoadFromFile(thePath+'Index_FK.bmp');
//Load PopupMenu Icons
thePath:=ExtractFilePath(Application.ExeName)+
'Gfx'+PathDelim+'Popup'+PathDelim;
if(Not(FileExists(thePath+'Select.png')))then
raise EInOutError.Create(DMMain.GetTranslatedMessage('File %s not found.', 209,
thePath+'Select.png'));
AddImgToPopupImgList(thePath+'Select.png');
if(Not(FileExists(thePath+'Edit.png')))then
raise EInOutError.Create(DMMain.GetTranslatedMessage('File %s not found.', 209,
thePath+'Edit.png'));
AddImgToPopupImgList(thePath+'Edit.png');
if(Not(FileExists(thePath+'Refresh.png')))then
raise EInOutError.Create(DMMain.GetTranslatedMessage('File %s not found.', 209,
thePath+'Refresh.png'));
AddImgToPopupImgList(thePath+'Refresh.png');
if(Not(FileExists(thePath+'Delete.png')))then
raise EInOutError.Create(DMMain.GetTranslatedMessage('File %s not found.', 209,
thePath+'Delete.png'));
AddImgToPopupImgList(thePath+'Delete.png');
if(Not(FileExists(thePath+'Copy.png')))then
raise EInOutError.Create(DMMain.GetTranslatedMessage('File %s not found.', 209,
thePath+'Copy.png'));
AddImgToPopupImgList(thePath+'Copy.png');
if(Not(FileExists(thePath+'Sql.png')))then
raise EInOutError.Create(DMMain.GetTranslatedMessage('File %s not found.', 209,
thePath+'Sql.png'));
AddImgToPopupImgList(thePath+'Sql.png');
//Load Align Icons
thePath:=ExtractFilePath(Application.ExeName)+
'Gfx'+PathDelim+'Popup'+PathDelim+'Align'+PathDelim;
if(Not(FileExists(thePath+'Top.png')))then
raise EInOutError.Create(DMMain.GetTranslatedMessage('File %s not found.', 209,
thePath+'Top.png'));
AddImgToPopupImgList(thePath+'Top.png');
if(Not(FileExists(thePath+'Right.png')))then
raise EInOutError.Create(DMMain.GetTranslatedMessage('File %s not found.', 209,
thePath+'Right.png'));
AddImgToPopupImgList(thePath+'Right.png');
if(Not(FileExists(thePath+'Bottom.png')))then
raise EInOutError.Create(DMMain.GetTranslatedMessage('File %s not found.', 209,
thePath+'Bottom.png'));
AddImgToPopupImgList(thePath+'Bottom.png');
if(Not(FileExists(thePath+'Left.png')))then
raise EInOutError.Create(DMMain.GetTranslatedMessage('File %s not found.', 209,
thePath+'Left.png'));
AddImgToPopupImgList(thePath+'Left.png');
if(Not(FileExists(thePath+'CenterH.png')))then
raise EInOutError.Create(DMMain.GetTranslatedMessage('File %s not found.', 209,
thePath+'CenterH.png'));
AddImgToPopupImgList(thePath+'CenterH.png');
if(Not(FileExists(thePath+'CenterV.png')))then
raise EInOutError.Create(DMMain.GetTranslatedMessage('File %s not found.', 209,
thePath+'CenterV.png'));
AddImgToPopupImgList(thePath+'CenterV.png');
if(Not(FileExists(thePath+'DistributeH.png')))then
raise EInOutError.Create(DMMain.GetTranslatedMessage('File %s not found.', 209,
thePath+'DistributeH.png'));
AddImgToPopupImgList(thePath+'DistributeH.png');
if(Not(FileExists(thePath+'DistributeV.png')))then
raise EInOutError.Create(DMMain.GetTranslatedMessage('File %s not found.', 209,
thePath+'DistributeV.png'));
AddImgToPopupImgList(thePath+'DistributeV.png');
//Load additional icons
thePath:=ExtractFilePath(Application.ExeName)+
'Gfx'+PathDelim+'Popup'+PathDelim;
if(Not(FileExists(thePath+'EditTableData.png')))then
raise EInOutError.Create(DMMain.GetTranslatedMessage('File %s not found.', 209,
thePath+'EditTableData.png'));
AddImgToPopupImgList(thePath+'EditTableData.png');
except
on x: Exception do
MessageDlg(DMMain.GetTranslatedMessage('ERROR: One of the Table Images could not be loaded. '#13#10+
'Please check the Gfx/Table directory.'#13#10'%s', 30, x.Message),
mtError, [mbOK], 0);
end;
end;
procedure TEERModel.LoadDataTypesFromIniFile;
var theIni: TMemIniFile;
i, j: integer;
theStringList, theDatatypeGroupsStringList: TStringList;
theDataTypeGroup: TEERDatatypeGroup;
theDataType: TEERDatatype;
s: string;
begin
//Clear Datatypes
Datatypes.Clear;
CommonDataType.Clear;
//Read IniFile
theIni:=TMemIniFile.Create(DMMain.SettingsPath+'DBDesigner4_DatabaseInfo.ini');
try
s:=Copy(theIni.ReadString(DatabaseType+'_QuoteCharacter', 'QuoteCharacter', '`'), 1, 1);
DBQuoteCharacter:=s[1];
theDatatypeGroupsStringList:=TStringList.Create;
theStringList:=TStringList.Create;
try
//Read all Datatype-Groups
theIni.ReadSectionValues(DatabaseType+'_Datatypes', theDatatypeGroupsStringList);
for i:=0 to theDatatypeGroupsStringList.Count-1 do
begin
theDatatypeGroupsStringList[i]:=Trim(Copy(theDatatypeGroupsStringList[i],
Pos('=', theDatatypeGroupsStringList[i])+1, Length(theDatatypeGroupsStringList[i])));
//Read all Datatypes in this group
theIni.ReadSectionValues(theDatatypeGroupsStringList[i], theStringList);
theDataTypeGroup:=TEERDatatypeGroup.Create(self);
theDataTypeGroup.GroupName:=theStringList.Values['Name'];
try
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -