📄 wwdatainspector.pas
字号:
if (lparam and $80000000)=0 then begin
if IsChildOfInspector(Inspector) then
begin
if not TrueFocusIsGrid then exit; // 4/4/03 - Don't process key if different window is open
// Send to inspector navigation keys
if (ac is TCustomEdit) then
begin
case wparam of
VK_LEFT:
if (Inspector.parent is TwwDBGrid) then // 6/13/02 - Left arrow can leave inspector when inspector is in grid
begin
if (not IsInExpandedGrid) and AllSelected then
begin
PostMessage(Inspector.Parent.handle, WM_KEYDOWN, wparam, 0);
result:=1;
end;
exit;
end
else if (Inspector.ColCount<=2) or (not LeftSide) then exit;
VK_Right:
if (Inspector.parent is TwwDBGrid) then // 6/13/02 - Left arrow can leave inspector when inspector is in grid
begin
if (not IsInExpandedGrid) and AllSelected then
begin
PostMessage(Inspector.Parent.handle, WM_KEYDOWN, wparam, 0);
result:=1;
end;
exit;
end
else if (Inspector.ColCount<=2) or (not RightSide) then exit;
// VK_RIGHT: if (Inspector.ColCount<=2) or (not RightSide) then exit;
end
end;
if Inspector.FCustomControlKeyMode then exit
else PostMessage(Inspector.handle, WM_KEYDOWN, wparam, 0);
result:=1;
end
end
else result:=1
end
end;
destructor TwwDataInspector.Destroy;
begin
if KeyHook<>0 then begin
UnhookWindowsHookEx(KeyHook);
KeyHook:= 0;
end;
FPaintOptions.Free;
FIndicators.Free;
FIndicators:=nil;
if Designer <> nil then
begin
Designer.Free;
end;
FreeHintWindow;
if HintTimer<>nil then
begin
HintTimer.enabled:= False;
HintTimer:=nil;
end;
FDesigner:= nil;
FItems.Free;
FCaptionFont.Free;
FCaptionFont:= Nil;
FDataLink.free;
FDataLink:= nil;
FPaintBitmap.Free;
FButtonOptions.Free;
FIndicatorRow.Free;
inherited;
end;
procedure TwwDataInspector.SetItems(Value: TwwInspectorCollection);
begin
FItems.Assign(Value);
// RowCount:= ActiveRows;
end;
procedure TwwDataInspector.SetDataSource(value : TDataSource);
begin
FDataLink.dataSource:= value;
end;
Function TwwDataInspector.GetDataSource: TDataSource;
begin
Result:= FdataLink.dataSource as TDataSource;
end;
Function TwwDataInspector.GetRowByItem(AItem: TwwInspectorItem): integer;
var curIndex, i: integer;
found: boolean;
function Scan(Item: TwwInspectorItem): boolean;
var i: Integer;
begin
Result:= True;
if Item=AItem then exit;
inc(curIndex);
if Item.Expanded then
begin
for i:= 0 to Item.Items.Count-1 do
if Item.Items[i].visible and Scan(Item.Items[i]) then begin
result:= True;
exit;
end
end;
result:=False;
end;
begin
if IndicatorRow.enabled then curIndex:= 1
else curIndex:=0;
found:= false;
for i:= 0 to Items.count-1 do
if Items[i].visible and Scan(Items[i]) then begin
found:= True;
break;
end ;
if not found then curIndex:= -1;
Result:= curIndex;
end;
Procedure TwwDataInspector.GetActiveRowsCallback(Item: TwwInspectorItem; UserData: Pointer; var AContinue: boolean);
begin
if Item.visible then
PInteger(UserData)^:= PInteger(UserData)^+1;
end;
Procedure TwwDataInspector.GetActiveItemCallback(Item: TwwInspectorItem; UserData: Pointer; var AContinue: boolean);
begin
if Item.visible then
begin
if PInteger(UserData)^=Row then begin
AContinue:= false;
FActiveItem:= Item;
end
else PInteger(UserData)^:= PInteger(UserData)^+1;
end
end;
Function TwwDataInspector.GetActiveRows: integer;
var ActiveRowCount: integer;
begin
if IndicatorRow.enabled then ActiveRowCount:=1
else ActiveRowCount:= 0;
IterateItems(GetActiveRowsCallBack, True, @ActiveRowCount);
Result:= ActiveRowCount;
end;
Function TwwDataInspector.RefreshActiveItem: TwwInspectorItem;
var ActiveRowCount: integer;
begin
if FastDesign then
begin
if IndicatorRow.enabled then ActiveRowCount:=1
else ActiveRowCount:= 0;
IterateItems(GetActiveItemCallBack, True, @ActiveRowCount);
Result:= FActiveItem;
end
else result:= ActiveItem;
end;
function TwwDataInspector.GetFirstChild(VisibleItemsOnly: boolean = True): TwwInspectorItem;
var i: integer;
begin
result:= nil;
for i:= 0 to Items.count-1 do begin
if (not VisibleItemsOnly) or TwwInspectorItem(Items[i]).visible then begin
result:= TwwInspectorItem(Items[i]);
break;
end
end;
end;
Function TwwDataInspector.GetTopItem: TwwInspectorItem;
begin
if FTopItem=nil then
begin
FTopItem:= GetFirstChild;
end;
if not FastDesign then
begin
FTopItem:= GetItemByRow(TopRow);
end;
result:= FTopItem;
end;
Function TwwDataInspector.GetItemByRow(ARow: integer; Optimize: boolean = True): TwwInspectorItem;
var curIndex: integer;
RetObjItem: TwwInspectorItem;
i: integer;
function Scan(Item: TwwInspectorItem): boolean;
var i: Integer;
begin
if not Item.visible then begin
Result:= False;
exit;
end;
Result:= True;
inc(curIndex);
if curIndex=ARow then
begin
RetObjItem:= Item;
exit;
end;
if Item.Expanded then
begin
for i:= 0 to Item.Items.Count-1 do
if Scan(Item.Items[i]) then break;
end;
result:=False;
end;
begin
if Optimize and FastDesign then
begin
if ARow=Row then begin
result:= ActiveItem;
exit;
end
else if (ARow>=TopRow) and (ARow<=TopRow+100) then
begin
retObjItem:= TopItem;
if retObjItem<>nil then begin
for i:= 1 to ARow-TopRow do
retObjItem:= retObjItem.GetNext(True);
end;
result:= retObjItem;
exit;
end
end;
if Row<0 then begin
result:= nil;
exit;
end;
curIndex:= -1;
if IndicatorRow.enabled then curIndex:=0;
retObjItem:= nil;
for i:= 0 to Items.count-1 do
if Scan(Items[i]) then break;
result:= retObjItem;
end;
Function TwwDataInspector.GetItemByCaption(ACaption: string): TwwInspectorItem;
var
curItem: TwwInspectorItem;
begin
result:= nil;
curItem:= GetFirstChild(False);
ACaption:= AnsiUppercase(ACaption);
while curItem<>nil do
begin
if AnsiUppercase(curItem.caption) = ACaption then
begin
result:= curItem;
break;
end;
curItem:= curItem.GetNext(False);
end;
end;
Function TwwDataInspector.GetItemByTagString(ATagString: string): TwwInspectorItem;
var
curItem: TwwInspectorItem;
begin
result:= nil;
curItem:= GetFirstChild(False);
ATagString:= AnsiUppercase(ATagString);
while curItem<>nil do
begin
if AnsiUppercase(curItem.tagstring) = ATagString then
begin
result:= curItem;
break;
end;
curItem:= curItem.GetNext(False);
end;
end;
Function TwwDataInspector.GetItemByFieldName(AFieldName: string): TwwInspectorItem;
var
curItem: TwwInspectorItem;
begin
result:= nil;
curItem:= GetFirstChild(False);
AFieldName:= AnsiUppercase(AFieldName);
while curItem<>nil do
begin
if AnsiUppercase(curItem.datafield) = AFieldName then
begin
result:= curItem;
break;
end;
curItem:= curItem.GetNext(False);
end;
end;
function TwwDataInspector.ButtonPt(ARect: TRect; Obj: TwwInspectorItem): TPoint;
var pt: TPoint;
MinY: integer;
tempHeight: integer;
begin
if Obj=nil then exit;
if ovCenterCaptionVert in Options then
begin
MinY:= (Canvas.TextHeight('Y')+2) div 2;
pt.y:= ARect.Top + wwMax(MinY, (ARect.Bottom-ARect.Top-2) div 2);
end
else begin
tempHeight:= Canvas.TextHeight('Y')+2;
if (not obj.Expanded) and (ButtonOptions.ExpandGlyph.Handle<>0) then
tempHeight:= wwMax(ButtonOptions.ExpandGlyph.Height, tempHeight)
else if (Obj.Expanded) and (ButtonOptions.CollapseGlyph.Handle<>0) then
tempHeight:= wwMax(ButtonOptions.CollapseGlyph.Height, tempHeight);
pt.y:= ARect.Top + (TempHeight) div 2;
end;
pt.x:= ARect.Left +(Obj.Level)*CaptionIndent + (CaptionIndent div 2) +1;
result:= pt
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -