MG: from Andrew: style list fixes, autosize for radio/checkbtns

git-svn-id: trunk@2079 -
This commit is contained in:
lazarus 2002-08-17 23:40:53 +00:00
parent e909c7698d
commit d536c331cd
4 changed files with 117 additions and 37 deletions

View File

@ -2102,7 +2102,9 @@ var
procedure DrawMark(iMark: integer);
var
iLine: integer;
itop : Longint;
begin
iTop := 0;
if Assigned(fBookMarkOpt.BookmarkImages) and not Marks[i].InternalImage then
begin
if Marks[iMark].ImageIndex <= fBookMarkOpt.BookmarkImages.Count then begin
@ -2112,9 +2114,11 @@ var
aGutterOffs^[iLine] := 0
else if aGutterOffs^[iLine] = 0 then
aGutterOffs^[iLine] := fBookMarkOpt.XOffset;
If fTextHeight > fBookMarkOpt.BookmarkImages.Height then
iTop := (fTextHeight - fBookMarkOpt.BookmarkImages.Height) div 2;
with fBookMarkOpt do
BookmarkImages.Draw(Canvas, LeftMargin + aGutterOffs^[iLine],
iLine * fTextHeight, Marks[iMark].ImageIndex,true);
iTop + iLine * fTextHeight, Marks[iMark].ImageIndex,true);
Inc(aGutterOffs^[iLine], fBookMarkOpt.XOffset);
end;
end else
@ -2158,7 +2162,8 @@ begin
fTextDrawer.Style := [];
// prepare the rect initially
rcLine := AClip;
rcLine.Right := Max(rcLine.Right, fGutterWidth - 2);
rcLine.Right := fGutterWidth - 2;
//rcLine.Right := Max(rcLine.Right, fGutterWidth - 2);
rcLine.Bottom := (FirstLine - TopLine) * fTextHeight;
for iLine := FirstLine to LastLine do begin
// next line rect
@ -2167,8 +2172,11 @@ begin
// erase the background and draw the line number string in one go
s := fGutter.FormatLineNumber(iLine);
{$IFDEF SYN_LAZARUS}
LCLLinux.ExtTextOut(DC, fGutter.LeftOffset, rcLine.Top, ETO_OPAQUE,
@rcLine, PChar(s), Length(s), nil);
InternalFillRect(DC, rcLine);
LCLLinux.DrawText(DC, PChar(S), Length(S), rcLine,
DT_RIGHT or DT_Center or DT_SINGLELINE or DT_NOPREFIX);
//LCLLinux.ExtTextOut(DC, fGutter.LeftOffset, rcLine.Top, ETO_OPAQUE,
// @rcLine, PChar(s), Length(s), nil);
{$ELSE}
Windows.ExtTextOut(DC, fGutter.LeftOffset, rcLine.Top, ETO_OPAQUE,
@rcLine, PChar(s), Length(s), nil);

View File

@ -21,13 +21,60 @@ begin
begin
inherited Create(AOwner);
fCompStyle := csCheckbox;
AutoSize := True;
end;
end;
{------------------------------------------------------------------------------
Method: TCheckbox.SetText
Params: Value : TCaption
Returns: nothing
Change the caption, and then AutoSize
------------------------------------------------------------------------------}
procedure TCheckbox.SetText(const Value: TCaption);
begin
Inherited SetText(Value);
AutoSize := FAutoSize;
end;
{------------------------------------------------------------------------------
Method: TCheckbox.SetAutoSize
Params: Value : Boolean
Returns: nothing
Sets AutoSize Flag, and if True, attempts to Size to fit Caption
------------------------------------------------------------------------------}
procedure TCheckbox.SetAutoSize(Value : Boolean);
var
R : TRect;
DC : hDC;
begin
FAutoSize := Value;
If not AutoSize then
Exit;
if not HandleAllocated then exit;
DC := GetDC(Handle);
Try
R := Rect(0,0, Width, Height);
DrawText(DC, PChar(Caption), Length(Caption), R,
DT_CalcRect or DT_NOPrefix);
If R.Right > Width then
Width := R.Right + 25;
If R.Bottom > Height then
Height := R.Bottom + 2;
Finally
ReleaseDC(Handle, DC);
end;
end;
// included by stdctrls.pp
{
$Log$
Revision 1.5 2002/08/24 06:51:22 lazarus
MG: from Andrew: style list fixes, autosize for radio/checkbtns
Revision 1.4 2002/07/23 07:40:51 lazarus
MG: fixed get widget position for inherited gdkwindows

View File

@ -54,6 +54,7 @@ begin
Hint := 'Radiobutton';
ShowHint := True;
fGroup := 0;
AutoSize := True;
end;
{------------------------------------------------------------------------------
@ -131,7 +132,7 @@ procedure TRadioButton.SetGroup(Value : THandle);
begin
Assert(False, 'Trace:IN SETGROUP. Caption = '+ Self.Caption);
FGroup := Value;
//SH? ReCreate;
RecreateWnd;
end;
{------------------------------------------------------------------------------
@ -146,41 +147,57 @@ begin
GetGroup := FGroup;
end;
{------------------------------------------------------------------------------
Method: TRadioButton.SetText
Params: Value: TCaption
Returns: nothing
Change the caption, and then recreate to update, then call to AutoSize
------------------------------------------------------------------------------}
procedure TRadioButton.SetText(const Value: TCaption);
begin
Inherited SetText(Value);
RecreateWnd;
AutoSize := FAutoSize;
end;
{------------------------------------------------------------------------------
Method: TCheckbox.SetAutoSize
Params: Value : Boolean
Returns: nothing
Sets AutoSize Flag, and if True, attempts to Size to fit Caption
------------------------------------------------------------------------------}
procedure TRadioButton.SetAutoSize(Value : Boolean);
var
R : TRect;
DC : hDC;
begin
FAutoSize := Value;
If not AutoSize then
Exit;
if not HandleAllocated then exit;
DC := GetDC(Handle);
Try
R := Rect(0,0, Width, Height);
DrawText(DC, PChar(Caption), Length(Caption), R,
DT_CalcRect or DT_NOPrefix);
If R.Right > 25 then
Width := R.Right + 25;
If R.Bottom > 25 then
Height := R.Bottom + 2;
Finally
ReleaseDC(Handle, DC);
end;
end;
// included by stdctrls.pp
(*
procedure TRadioButton.ReCreate;
//var
// ******************************
// the following line has been commented out so that gtk dependency can be
// removed from all files. The following function needs to be moved. MAH
//
// gLabel : PgChar;
begin
if Caption = '' then
Caption := 'RadioGroup1';
// ******************************
// the following line has been commented out so that gtk dependency can be
// removed from all files. The following function needs to be moved. MAH
//
// gLAbel := StrAlloc(length(Self.Caption) + 1);
// StrPCopy(gLabel,Self.Caption);
// ******************************
// the following line has been commented out so that gtk dependency can be
// removed from all files. The following function needs to be moved. MAH
//
// FComponent := gtk_radio_button_new_with_label(
// gtk_radio_button_group(GTk_Radio_Button(Group.FComponent)),gLabel);
// gtkGroup := gtk_radio_button_group(GTk_Radio_Button(Group.FComponent));
end;
*)
{
$Log$
Revision 1.6 2002/08/24 06:51:22 lazarus
MG: from Andrew: style list fixes, autosize for radio/checkbtns
Revision 1.5 2002/05/13 14:47:00 lazarus
MG: fixed client rectangles, TRadioGroup, RecreateWnd

View File

@ -18,8 +18,12 @@ function gtkLVHScroll(AList: PGTKCList; AData: gPointer): GBoolean; cdecl;
var
Adjustment: PGTKAdjustment;
begin
{$IfNDef Win32}
Adjustment := gtk_clist_get_hadjustment(AList);
if Adjustment = nil
{$Else}
Adjustment := nil;
{$EndIf}
if Adjustment = nil
then Result := False
else Result := GTKHScrollCB(Adjustment, AData);
end;
@ -30,8 +34,12 @@ function gtkLVVScroll(AList: PGTKCList; AData: gPointer): GBoolean; cdecl;
var
Adjustment: PGTKAdjustment;
begin
{$IfNDef Win32}
Adjustment := gtk_clist_get_vadjustment(AList);
if Adjustment = nil
{$Else}
Adjustment := nil;
{$EndIf}
if Adjustment = nil
then Result := False
else Result := GTKVScrollCB(Adjustment, AData);
end;