fixed grids TComboBox from Jesus

git-svn-id: trunk@5325 -
This commit is contained in:
mattias 2004-03-18 22:26:24 +00:00
parent 395608d032
commit 5d5cdec72a
2 changed files with 127 additions and 45 deletions

View File

@ -290,6 +290,7 @@ type
FOnSelection: TOnSelectEvent; FOnSelection: TOnSelectEvent;
FOnTopLeftChanged: TNotifyEvent; FOnTopLeftChanged: TNotifyEvent;
FSkipUnselectable: Boolean; FSkipUnselectable: Boolean;
FGSMHBar, FGSMVBar: Integer; // Scrollbar's metrics
procedure AdjustCount(IsColumn:Boolean; OldValue, NewValue:Integer); procedure AdjustCount(IsColumn:Boolean; OldValue, NewValue:Integer);
procedure CacheVisibleGrid; procedure CacheVisibleGrid;
@ -351,6 +352,7 @@ type
procedure WriteColWidths(Writer: TWriter); procedure WriteColWidths(Writer: TWriter);
procedure WriteRowHeights(Writer: TWriter); procedure WriteRowHeights(Writer: TWriter);
procedure WMEraseBkgnd(var message: TLMEraseBkgnd); message LM_ERASEBKGND; procedure WMEraseBkgnd(var message: TLMEraseBkgnd); message LM_ERASEBKGND;
procedure WMGetDlgCode(var Msg: TLMNoParams); message LM_GETDLGCODE;
procedure WMSize(var Msg: TLMSize); message LM_SIZE; procedure WMSize(var Msg: TLMSize); message LM_SIZE;
procedure WMChar(var message: TLMChar); message LM_CHAR; procedure WMChar(var message: TLMChar); message LM_CHAR;
protected protected
@ -412,7 +414,7 @@ type
procedure SaveContent(cfg: TXMLConfig); virtual; procedure SaveContent(cfg: TXMLConfig); virtual;
procedure ScrollBarRange(Which:Integer; IsVisible:boolean; aRange: Integer); procedure ScrollBarRange(Which:Integer; IsVisible:boolean; aRange: Integer);
procedure ScrollBarPosition(Which, Value: integer); procedure ScrollBarPosition(Which, Value: integer);
function ScrollBarIsVisible(Which:Integer): Boolean; //function ScrollBarIsVisible(Which:Integer): Boolean;
procedure ScrollBarPage(Which: Integer; aPage: Integer); procedure ScrollBarPage(Which: Integer; aPage: Integer);
procedure ScrollBarShow(Which: Integer; aValue: boolean); procedure ScrollBarShow(Which: Integer; aValue: boolean);
function ScrollBarAutomatic(Which: TScrollStyle): boolean; virtual; function ScrollBarAutomatic(Which: TScrollStyle): boolean; virtual;
@ -735,11 +737,70 @@ begin
I2:=Tmp; I2:=Tmp;
end; end;
{$ifdef GridTraceMsg}
function TransMsg(const S: String; const TheMsg: TLMessage): String;
var
hex: string;
begin
with TheMsg do begin
hex:= S + '['+IntToHex(msg, 8)+'] W='+IntToHex(WParam,8)+' L='+IntToHex(LParam,8)+' ';
case Msg of
CM_BASE..CM_MOUSEWHEEL:
case Msg of
CM_MOUSEENTER: WriteLn(hex, 'CM_MOUSEENTER');
CM_MOUSELEAVE: WriteLn(hex, 'CM_MOUSELEAVE');
CM_TEXTCHANGED: WriteLn(hex, 'CM_TEXTCHANGED');
CM_PARENTCTL3DCHANGED: WriteLn(hex, 'CM_PARENTCTL3DCHANGED');
CM_UIACTIVATE: WriteLn(hex, 'CM_UIACTIVATE');
CM_CONTROLLISTCHANGE: WriteLn(hex, 'CM_CONTROLLISTCHANGE');
CM_PARENTCOLORCHANGED: WriteLn(hex, 'CM_PARENTCOLORCHANGED');
CM_PARENTFONTCHANGED: WriteLn(hex, 'CM_PARENTFONTCHANGED');
CM_PARENTSHOWHINTCHANGED: WriteLn(hex, 'CM_PARENTSHOWHINTCHANGED');
CM_PARENTBIDIMODECHANGED: WriteLn(hex, 'CM_PARENTBIDIMODECHANGED');
CM_CONTROLCHANGE: WriteLn(Hex, 'CM_CONTROLCHANGE');
CM_SHOWINGCHANGED: WriteLn(Hex, 'CM_SHOWINGCHANGED');
CM_VISIBLECHANGED: WriteLn(Hex, 'CM_VISIBLECHANGED');
else WriteLn(Hex, 'CM_BASE + ', Msg - CM_BASE);
end;
else
case Msg of
//CN_BASE MESSAGES
CN_COMMAND: WriteLn(hex, 'LM_CNCOMMAND');
// NORMAL MESSAGES
LM_SETFOCUS: WriteLn(hex, 'LM_SetFocus');
LM_LBUTTONDOWN: WriteLn(hex, 'LM_MOUSEDOWN');
LM_LBUTTONUP: WriteLn(hex, 'LM_LBUTTONUP');
LM_RBUTTONDOWN: WriteLn(hex, 'LM_RBUTTONDOWN');
LM_RBUTTONUP: WriteLn(hex, 'LM_RBUTTONUP');
LM_GETDLGCODE: WriteLn(hex, 'LM_GETDLGCODE');
LM_KEYDOWN: WriteLn(hex, 'LM_KEYDOWN');
LM_KEYUP: WriteLn(hex, 'LM_KEYUP');
LM_CAPTURECHANGED: WriteLn(hex, 'LM_CAPTURECHANGED');
LM_ERASEBKGND: WriteLn(hex, 'LM_ERASEBKGND');
LM_KILLFOCUS: WriteLn(hex, 'LM_KILLFOCUS');
LM_CHAR: WriteLn(hex, 'LM_CHAR');
LM_SHOWWINDOW: WriteLn(hex, 'LM_SHOWWINDOW');
LM_SIZE: WriteLn(hex, 'LM_SIZE');
LM_WINDOWPOSCHANGED: WriteLn(hex, 'LM_WINDOWPOSCHANGED');
LM_HSCROLL: WriteLn(hex, 'LM_HSCROLL');
LM_VSCROLL: WriteLn(hex, 'LM_VSCROLL');
LM_MOUSEMOVE: ;//WriteLn(hex, 'LM_MOUSEMOVE');
LM_MOUSEWHEEL: WriteLn(Hex, 'LM_MOUSEWHEEL');
else WriteLn(hex, GetMessageName(Msg));
end;
end;
end;
end;
{$Endif GridTraceMsg}
{ TCustomGrid } { TCustomGrid }
function TCustomGrid.Getrowheights(Arow: Integer): Integer; function TCustomGrid.Getrowheights(Arow: Integer): Integer;
begin begin
Result:=Integer(FRows[aRow]); if aRow<RowCount then Result:=Integer(FRows[aRow])
else Result:=-1;
if Result<0 then Result:=fDefRowHeight; if Result<0 then Result:=fDefRowHeight;
end; end;
@ -781,7 +842,8 @@ end;
function TCustomGrid.Getcolwidths(Acol: Integer): Integer; function TCustomGrid.Getcolwidths(Acol: Integer): Integer;
begin begin
Result:=Integer(FCols[aCol]); if aCol<ColCount then Result := Integer(FCols[aCol])
else Result := -1;
if result<0 then Result:=fDefColWidth; if result<0 then Result:=fDefColWidth;
end; end;
@ -1107,8 +1169,8 @@ begin
FGCache.TLRowOff:=0; FGCache.TLRowOff:=0;
end; end;
Dh:=18; //GetSystemMetrics(SM_CYHSCROLL); Dh:=FGSMHBar;
DV:=18; //GetSystemMetrics(SM_CXVSCROLL); DV:=FGSMVBar;
TW:=FGCache.GridWidth; TW:=FGCache.GridWidth;
TH:=FGCache.GridHeight; TH:=FGCache.GridHeight;
@ -1142,7 +1204,7 @@ begin
if ScrollBarAutomatic(ssHorizontal) then begin if ScrollBarAutomatic(ssHorizontal) then begin
if HSbVisible then begin if HSbVisible then begin
HsbRange:=GridWidth + 2 + dv; HsbRange:=GridWidth + 2 {+ dv};
if not (goSmoothScroll in Options) then begin if not (goSmoothScroll in Options) then begin
TW:= Integer(AccumWidth[MaxTopLeft.X])-(HsbRange-ClientWidth); TW:= Integer(AccumWidth[MaxTopLeft.X])-(HsbRange-ClientWidth);
@ -1164,7 +1226,7 @@ begin
with FGCache do with FGCache do
if ScrollBarAutomatic(ssVertical) then begin if ScrollBarAutomatic(ssVertical) then begin
if VSbVisible then begin if VSbVisible then begin
VSbRange:= GridHeight + 2 + dh; VSbRange:= GridHeight + 2{ + dh};
if not (goSmoothScroll in Options) then begin if not (goSmoothScroll in Options) then begin
TH:= Integer(accumHeight[MaxTopLeft.Y])-(VsbRange-ClientHeight); TH:= Integer(accumHeight[MaxTopLeft.Y])-(VsbRange-ClientHeight);
@ -1234,7 +1296,7 @@ begin
SetScrollInfo(Handle, Which, ScrollInfo, True); SetScrollInfo(Handle, Which, ScrollInfo, True);
end; end;
end; end;
{
function TCustomGrid.ScrollBarIsVisible(Which: Integer): Boolean; function TCustomGrid.ScrollBarIsVisible(Which: Integer): Boolean;
begin begin
Result:=false; Result:=false;
@ -1242,7 +1304,7 @@ begin
Result:= getScrollbarVisible(handle, Which); Result:= getScrollbarVisible(handle, Which);
end; end;
end; end;
}
procedure TCustomGrid.ScrollBarPage(Which: Integer; aPage: Integer); procedure TCustomGrid.ScrollBarPage(Which: Integer; aPage: Integer);
var var
ScrollInfo: TScrollInfo; ScrollInfo: TScrollInfo;
@ -1765,9 +1827,14 @@ end;
procedure TCustomGrid.WMEraseBkgnd(var message: TLMEraseBkgnd); procedure TCustomGrid.WMEraseBkgnd(var message: TLMEraseBkgnd);
begin begin
message.Result:=1; message.Result:=1;
WriteLn('TCustomGrid.WMEraseBkgnd'); //WriteLn('TCustomGrid.WMEraseBkgnd');
end; end;
procedure TCustomGrid.WMGetDlgCode(var Msg: TLMNoParams);
begin
Msg.Result := DLGC_WANTARROWS or DLGC_WANTCHARS or DLGC_WANTALLKEYS;
if goTabs in Options then Msg.Result:= Msg.Result or DLGC_WANTTAB;
end;
// //
// NOTE: WMHScroll and VMHScroll // NOTE: WMHScroll and VMHScroll
@ -1776,14 +1843,16 @@ end;
procedure TCustomGrid.WMHScroll(var message: TLMHScroll); procedure TCustomGrid.WMHScroll(var message: TLMHScroll);
var var
C,TL,CTL: Integer; C,TL,CTL: Integer;
R: TRect;
begin begin
// Avoid invalidating right know, just let the scrollbar // Avoid invalidating right know, just let the scrollbar
// calculate its position // calculate its position
{
BeginUpdate; BeginUpdate;
Inherited; Inherited;
message.Result:=1; message.Result:=1;
EndUpdate(uoNone); EndUpdate(uoNone);
}
{$IfDef dbgScroll} {$IfDef dbgScroll}
WriteLn('HSCROLL: Code=',message.ScrollCode,' Position=', message.Pos); WriteLn('HSCROLL: Code=',message.ScrollCode,' Position=', message.Pos);
@ -1823,7 +1892,14 @@ begin
SB_ENDSCROLL: Exit; SB_ENDSCROLL: Exit;
end; end;
{$Ifdef dbgScroll}
WriteLn('---- Position=',C, ' FixedWidth=',FGCache.FixedWidth);
{$Endif}
ScrollBarPosition(SB_HORZ, C);
C:= C + FGCache.FixedWidth; C:= C + FGCache.FixedWidth;
{$Ifdef dbgScroll}
WriteLn('---- Position=',C, ' FixedWidth=',FGCache.FixedWidth);
{$Endif}
TL:=OffsetToColRow(True, False, C, FGCache.TLColOff); TL:=OffsetToColRow(True, False, C, FGCache.TLColOff);
{$Ifdef dbgScroll} {$Ifdef dbgScroll}
WriteLn('---- Offset=',C, ' TL=',TL,' TLColOFf=', FGCache.TLColOff); WriteLn('---- Offset=',C, ' TL=',TL,' TLColOFf=', FGCache.TLColOff);
@ -1837,10 +1913,12 @@ begin
end else end else
if goSmoothScroll in Options then begin if goSmoothScroll in Options then begin
CacheVisibleGrid; CacheVisibleGrid;
{
R.Topleft:=Point(FGCache.FixedWidth, 0); R.Topleft:=Point(FGCache.FixedWidth, 0);
R.BottomRight:= FGCache.MaxClientXY; R.BottomRight:= FGCache.MaxClientXY;
InvalidateRect(Handle, @R, false); InvalidateRect(Handle, @R, false);
//Invalidate; }
Invalidate;
end; end;
end; end;
end; end;
@ -1848,15 +1926,15 @@ end;
procedure TCustomGrid.WMVScroll(var message: TLMVScroll); procedure TCustomGrid.WMVScroll(var message: TLMVScroll);
var var
C, TL, CTL: Integer; C, TL, CTL: Integer;
R: TRect;
begin begin
// Avoid invalidating right know, just let the scrollbar // Avoid invalidating right know, just let the scrollbar
// calculate its position // calculate its position
{
BeginUpdate; BeginUpdate;
Inherited; Inherited;
message.Result:=1; message.Result:=1;
EndUpdate(uoNone); EndUpdate(uoNone);
}
{$IfDef dbgScroll} {$IfDef dbgScroll}
WriteLn('VSCROLL: Code=',message.ScrollCode,' Position=', message.Pos); WriteLn('VSCROLL: Code=',message.ScrollCode,' Position=', message.Pos);
{$Endif} {$Endif}
@ -1892,7 +1970,14 @@ begin
SB_ENDSCROLL: Exit; SB_ENDSCROLL: Exit;
end; end;
{$Ifdef dbgScroll}
WriteLn('---- Position=',C, ' FixedHeight=',FGCache.FixedHeight);
{$Endif}
ScrollBarPosition(SB_VERT, C);
C:= C + FGCache.FixedHeight; C:= C + FGCache.FixedHeight;
{$Ifdef dbgScroll}
WriteLn('---- NewPosition=',C);
{$Endif}
TL:=OffsetToColRow(False, False, C, FGCache.TLRowOff); TL:=OffsetToColRow(False, False, C, FGCache.TLRowOff);
{$Ifdef dbgScroll} {$Ifdef dbgScroll}
WriteLn('---- Offset=',C, ' TL=',TL, ' TLRowOFf=', FGCache.TLRowOff); WriteLn('---- Offset=',C, ' TL=',TL, ' TLRowOFf=', FGCache.TLRowOff);
@ -1906,10 +1991,12 @@ begin
end else end else
if goSmoothScroll in Options then begin if goSmoothScroll in Options then begin
CacheVisibleGrid; CacheVisibleGrid;
{
R.TopLeft:=Point(0, FGCache.FixedHeight); R.TopLeft:=Point(0, FGCache.FixedHeight);
R.BottomRight:=FGCache.MaxClientXY; R.BottomRight:=FGCache.MaxClientXY;
InvalidateRect(Handle, @R, false); InvalidateRect(Handle, @R, false);
//Invalidate; }
Invalidate;
end; end;
end; end;
end; end;
@ -1935,25 +2022,16 @@ end;
procedure TCustomGrid.WndProc(var TheMessage: TLMessage); procedure TCustomGrid.WndProc(var TheMessage: TLMessage);
begin begin
{ {$IfDef GridTraceMsg}
case TheMessage.Msg of TransMsg('GRID: ', TheMessage);
LM_SETFOCUS: {$Endif}
begin
(* with TheMessage do
write('LM_SETFOCUS RECIBIDO'); if (csDesigning in ComponentState) and
if FExchangingFocus then begin ((Msg = LM_HSCROLL)or(Msg = LM_VSCROLL))
WriteLn(' - AVOIDING'); then
Exit; Exit;
end else WriteLn;
*)
end;
LM_LBUTTONDOWN: WriteLn('LM_MOUSEDOWN');
CM_MOUSEENTER: WriteLn('CM_MOUSEENTER');
CM_MOUSELEAVE: WriteLn('CM_MOUSELEAVE');
LM_MOUSEMOVE: WriteLn('LM_MOUSEMOVE');
end;
}
inherited WndProc(TheMessage); inherited WndProc(TheMessage);
end; end;
@ -1990,21 +2068,21 @@ begin
// Special condition only When scrolling by draging // Special condition only When scrolling by draging
// the scrollbars see: WMHScroll and WVHScroll // the scrollbars see: WMHScroll and WVHScroll
if FUpdateScrollBarsCount=0 then begin if FUpdateScrollBarsCount=0 then begin
if Which in [ssHorizontal, ssBoth] then if Which in [ssHorizontal, ssBoth] then begin
if ScrollBarAutomatic(ssHorizontal) and if ScrollBarAutomatic(ssHorizontal) Then begin
ScrollBarIsVisible(SB_HORZ) then begin
with FGCache do with FGCache do
ScrollBarPosition(SB_HORZ, ScrollBarPosition(SB_HORZ,
Integer(AccumWidth[FTopLeft.x])-TLColOff-FixedWidth ); Integer(AccumWidth[FTopLeft.x])-TLColOff-FixedWidth );
end; end;
end;
if Which in [ssVertical, ssBoth] then if Which in [ssVertical, ssBoth] then begin
if ScrollbarAutomatic(ssVertical) and if ScrollBarAutomatic(ssVertical) then begin
ScrollbarIsVisible(SB_VERT) then begin
with FGCache do with FGCache do
ScrollBarPosition(SB_VERT, ScrollBarPosition(SB_VERT,
Integer(AccumHeight[FTopLeft.y])-TLRowOff-FixedHeight); Integer(AccumHeight[FTopLeft.y])-TLRowOff-FixedHeight);
end; end;
end;
end; {if FUpd...} end; {if FUpd...}
end; end;
@ -2249,6 +2327,7 @@ begin
end; end;
end; end;
while Offset>(Integer(AccumWidth[Result])+GetColWidths(Result)-1) do Inc(Result); while Offset>(Integer(AccumWidth[Result])+GetColWidths(Result)-1) do Inc(Result);
Rest:=Offset; Rest:=Offset;
if Result<>0 then Rest:=Offset-Integer(AccumWidth[Result]); if Result<>0 then Rest:=Offset-Integer(AccumWidth[Result]);
@ -2372,7 +2451,7 @@ begin
if not FGCache.ValidGrid then Exit; if not FGCache.ValidGrid then Exit;
if not (ssLeft in Shift) then Exit; if not (ssLeft in Shift) then Exit;
//if csDesigning in componentState then Exit; if csDesigning in componentState then Exit;
{$IfDef dbgFocus} WriteLn('MouseDown INIT'); {$Endif} {$IfDef dbgFocus} WriteLn('MouseDown INIT'); {$Endif}
@ -2408,7 +2487,6 @@ begin
if Not (csDesigning in componentState) then begin if Not (csDesigning in componentState) then begin
fGridState:=gsSelecting; fGridState:=gsSelecting;
FSplitter:=MouseToCell(Point(X,Y)); FSplitter:=MouseToCell(Point(X,Y));
if Not Focused then setFocus; if Not Focused then setFocus;
if not (goEditing in Options) then begin if not (goEditing in Options) then begin
@ -3419,6 +3497,8 @@ begin
FRows:=TList.Create; FRows:=TList.Create;
FGCache.AccumWidth:=TList.Create; FGCache.AccumWidth:=TList.Create;
FGCache.AccumHeight:=TList.Create; FGCache.AccumHeight:=TList.Create;
FGSMHBar := GetSystemMetrics(SM_CYHSCROLL);
FGSMVBar := GetSystemMetrics(SM_CXVSCROLL);
inherited Create(AOwner); inherited Create(AOwner);
//AutoScroll:=False; //AutoScroll:=False;
FDefaultDrawing := True; FDefaultDrawing := True;

View File

@ -927,12 +927,10 @@ activate_time : the time at which the activation event occurred.
case TControl(Sender).FCompStyle of case TControl(Sender).FCompStyle of
csComboBox: csComboBox:
begin begin
SendMessage(Handle, CB_SETEDITSEL, 0, SendMessage(Handle, CB_SETEDITSEL, 0, MakeLParam(integer(Data), integer(Data)));
MakeLParam(Word(Integer(Data)), High(Word)));
end; end;
csEdit: csEdit:
begin begin
//WriteLn('LM_SETSELSTART: Start=',Integer(Data));
SendMessage(Handle, EM_SETSEL, Windows.WParam(Data), Windows.LParam(Data)); SendMessage(Handle, EM_SETSEL, Windows.WParam(Data), Windows.LParam(Data));
end; end;
end; end;
@ -943,13 +941,14 @@ activate_time : the time at which the activation event occurred.
Case TControl(Sender).FCompStyle of Case TControl(Sender).FCompStyle of
csComboBox: csComboBox:
begin begin
Windows.SendMessage(Handle, CB_SETCURSEL, Windows.WParam(Data), 0); Windows.SendMessage(Handle, CB_GETEDITSEL, Windows.Wparam(@i), Windows.LParam(@Num));
Num := i + Integer(Data);
Windows.SendMessage(Handle, CB_SETEDITSEL, 0, MakeLParam( i, Num ));
end; end;
csEdit: csEdit:
begin begin
Windows.SendMessage(Handle, EM_GETSEL, Windows.Wparam(@i), Windows.LParam(@Num)); Windows.SendMessage(Handle, EM_GETSEL, Windows.Wparam(@i), Windows.LParam(@Num));
Num := i + Integer(Data); Num := i + Integer(Data);
//WriteLn('LM_SETSELLEN: Start=',i, ' End= ',Num, 'Length=',Integer(Data));
Windows.SendMessage(Handle, EM_SETSEL, Windows.WParam(i), Windows.LParam(Num)); Windows.SendMessage(Handle, EM_SETSEL, Windows.WParam(i), Windows.LParam(Num));
end; end;
end; end;
@ -3025,6 +3024,9 @@ End;
{ {
$Log$ $Log$
Revision 1.183 2004/03/18 22:26:24 mattias
fixed grids TComboBox from Jesus
Revision 1.182 2004/03/07 12:55:53 micha Revision 1.182 2004/03/07 12:55:53 micha
don't create window for image don't create window for image