fixed removing TStatusBar panels in gtk

git-svn-id: trunk@5144 -
This commit is contained in:
mattias 2004-02-02 19:48:01 +00:00
parent 9b18df1e0e
commit b459b13b8b
7 changed files with 37 additions and 201 deletions

View File

@ -4040,9 +4040,7 @@ begin
or (TempEditor.EditorComponent.CaretX<>TempEditor.fErrorColumn) then
TempEditor.ErrorLine:=-1;
{$IFNDEF OldStatusBar}
Statusbar.BeginUpdate;
{$ENDIF}
if snIncrementalFind in States then begin
Statusbar.SimplePanel:=true;
Statusbar.SimpleText:=Format(lisUESearching, [IncrementalSearchStr]);
@ -4076,9 +4074,7 @@ begin
Statusbar.Panels[2].Text := PanelCharMode;
Statusbar.Panels[3].Text := PanelFilename;
end;
{$IFNDEF OldStatusBar}
Statusbar.EndUpdate;
{$ENDIF}
End;
function TSourceNotebook.FindBookmark(BookmarkID: integer): TSourceEditor;

View File

@ -287,6 +287,7 @@ type
function GetPropInfo:PPropInfo;
function GetFloatValue:Extended;
function GetFloatValueAt(Index:Integer):Extended;
function GetDefaultFloatValue:Extended;
function GetInt64Value:Int64;
function GetInt64ValueAt(Index:Integer):Int64;
function GetMethodValue:TMethod;
@ -2020,6 +2021,11 @@ begin
with FPropList^[Index] do Result:=GetFloatProp(Instance,PropInfo);
end;
function TPropertyEditor.GetDefaultFloatValue: Extended;
begin
end;
function TPropertyEditor.GetMethodValue:TMethod;
begin
Result:=GetMethodValueAt(0);

View File

@ -102,44 +102,28 @@ type
TStatusBar = Class(TWinControl)
private
{$IFDEF OldStatusBar}
FCanvas : TCanvas;
{$ELSE}
FHandlePanelCount: integer; // realized panels in the Handle object
FHandleObjectNeedsUpdate: boolean;
FHandleUpdatePanelIndex: integer; // which panel in the handle object needs update
FUpdateLock: integer; // set by BeginUpdate/EndUpdate
{$ENDIF}
FPanels : TStatusPanels;
FSimpleText : String;
FSimplePanel : Boolean;
procedure SetPanels(Value: TStatusPanels);
procedure SetSimpleText(const Value : String);
procedure SetSimplePanel(Value : Boolean);
{$IFDEF OldStatusBar}
Procedure WMPaint(var Msg: TLMPaint); message LM_PAINT;
Procedure DrawDivider(X : Integer);
Procedure DrawBevel(xLeft, PanelNum : Integer);
{$ELSE}
protected
procedure CreateWnd; override;
procedure DestroyWnd; override;
procedure Loaded; override;
procedure UpdateHandleObject(PanelIndex: integer); virtual;
{$ENDIF}
public
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override;
procedure InvalidatePanel(PanelIndex: integer; PanelParts: TPanelParts); virtual;
{$IFNDEF OldStatusBar}
procedure BeginUpdate;
procedure EndUpdate;
function UpdatingStatusBar: boolean;
{$ELSE}
procedure GetPanelRect(PanelIndex: integer; var ARect: TRect);
public
property Canvas: TCanvas read FCanvas;
{$ENDIF}
published
property Panels: TStatusPanels read FPanels write SetPanels;
property SimpleText: String read FSimpleText write SetSimpleText;
@ -1970,6 +1954,9 @@ end.
{ =============================================================================
$Log$
Revision 1.104 2004/02/02 19:48:01 mattias
fixed removing TStatusBar panels in gtk
Revision 1.103 2004/01/21 10:19:16 micha
enable tabstops for controls; implement tabstops in win32 intf

View File

@ -19,17 +19,21 @@
{-----------------------------------------------------------------------------}
procedure TSpinEdit.UpdateControl;
begin
if not HandleAllocated then exit;
if MaxValue<MinValue then fMaxValue:=MinValue;
if Value<fMinValue then Value:=fMinValue;
if Value>fMaxValue then Value:=fMaxValue;
if (not HandleAllocated) then exit;
if ([csLoading,csDestroying]*ComponentState<>[]) then begin
fValueNeedsUpdate:=true;
exit;
end;
CNSendMessage(LM_SetProperties,Self,nil);
fValueNeedsUpdate:=false;
end;
function TSpinEdit.ValueIsStored: boolean;
begin
Result:=Value<>1;
Result:=true; // fpc bug, default value is always 0
end;
procedure TSpinEdit.SetMaxValue(const AValue: single);
@ -46,12 +50,12 @@ end;
function TSpinEdit.MaxValueIsStored: boolean;
begin
Result:=fMaxValue<>100;
Result:=true; // fpc bug, default value is always 0
end;
function TSpinEdit.MinValueIsStored: boolean;
begin
Result:=fMinValue<>1;
Result:=true; // fpc bug, default value is always 0
end;
@ -77,6 +81,12 @@ begin
UpdateControl;
end;
procedure TSpinEdit.Loaded;
begin
inherited Loaded;
if fValueNeedsUpdate then UpdateControl;
end;
{-----------------------------------------------------------------------------}
Procedure TSpinEdit.SetValue(num : Single);
begin
@ -114,9 +124,9 @@ begin
fClimbRate := 1;
fDecimals := 2;
fValue := 1;
fValue := 0;
fValueNeedsUpdate := true;
fMinValue := 1;
fMinValue := 0;
fMaxValue := 100;
SetBounds(1,1,50,20);

View File

@ -24,10 +24,6 @@ begin
ControlStyle := [csCaptureMouse, csClickEvents, csDoubleClicks, csOpaque];
FSimplePanel := True;
FPanels := TStatusPanels.Create(Self);
{$IFDEF OldStatusBar}
FCanvas := TControlCanvas.Create;
TControlCanvas(FCanvas).Control := Self;
{$ENDIF}
Color := clBtnFace;
Anchors:=[akLeft,akRight,akBottom];
Align := alBottom;
@ -43,11 +39,7 @@ begin
if FSimpleText <> value then
begin
FSimpleText := Value;
{$IFDEF OldStatusBar}
Invalidate;
{$ELSE}
if HandleAllocated and FSimplePanel then StatusBarSetText(Self,0);
{$ENDIF}
end;
end;
@ -56,11 +48,7 @@ Begin
if FSimplePanel <> Value then
Begin
FSimplePanel := Value;
{$IFDEF OldStatusBar}
Invalidate;
{$ELSE}
UpdateHandleObject(-1);
{$ENDIF}
end;
End;
@ -75,13 +63,9 @@ end;
destructor TStatusBar.Destroy;
begin
FreeThenNil(FPanels);
{$IFDEF OldStatusBar}
FreeThenNil(FCanvas);
{$ENDIF}
inherited Destroy;
end;
{$IFNDEF OldStatusBar}
procedure TStatusBar.CreateWnd;
begin
inherited CreateWnd;
@ -167,7 +151,6 @@ function TStatusBar.UpdatingStatusBar: boolean;
begin
Result:=FUpdateLock>0;
end;
{$ENDIF not OldStatusBar}
{------------------------------------------------------------------------------
procedure TStatusBar.InvalidatePanel(PanelIndex: integer;
@ -175,164 +158,10 @@ end;
------------------------------------------------------------------------------}
procedure TStatusBar.InvalidatePanel(PanelIndex: integer;
PanelParts: TPanelParts);
{$IFDEF OldStatusBar}
var
PanelRect, TextRect: TRect;
{$ENDIF}
begin
if (PanelParts=[]) then exit;
{$IFNDEF OldStatusBar}
UpdateHandleObject(PanelIndex);
{$ELSE}
if (not HandleAllocated) or (csLoading in ComponentState) then exit;
if ppWidth in PanelParts then begin
Invalidate;
end else begin
GetPanelRect(PanelIndex,PanelRect);
if ppText in PanelParts then begin
TextRect:=PanelRect;
inc(TextRect.Left);
inc(TextRect.Top);
dec(TextRect.Right);
dec(TextRect.Bottom);
InvalidateRect(Handle,@TextRect,false);
end;
if ppBorder in PanelParts then begin
InvalidateFrame(Handle,@PanelRect,false,2);
end;
end;
{$ENDIF}
end;
{$IFDEF OldStatusBar}
{------------------------------------------------------------------------------
procedure TStatusBar.GetPanelRect(PanelIndex: integer; var ARect: TRect);
------------------------------------------------------------------------------}
procedure TStatusBar.GetPanelRect(PanelIndex: integer; var ARect: TRect);
var
i: Integer;
begin
ARect.Left:=0;
ARect.Top:=0;
ARect.Bottom:=ClientHeight;
for i:=0 to PanelIndex-1 do
inc(ARect.Left,Panels[i].Width);
if PanelIndex = Panels.Count-1 then begin
ARect.Right:=ClientWidth-ARect.Left;
if ARect.Right<ARect.Left then
ARect.Right:=ARect.Left;
end
else
ARect.Right:=ARect.Left+Panels[PanelIndex].Width;
end;
{------------------------------------------------------------------------------
TStatusBar DrawBevel
------------------------------------------------------------------------------}
Procedure TStatusBar.DrawBevel(xLeft, PanelNum : Integer );
var
LeftTopColor,RightBottomColor:TColor;
I, PL, PW : Longint;
Begin
if PanelNum = Panels.Count-1 then begin
PL := Left;
If Panels.Count > 1 then
For I := 0 to Panels.Count-2 do
PL := PL + Panels[I].Width;
PW := ClientWidth - PL;
end
else
PW := Panels[PanelNum].Width;
if PW<=0 then exit;
if (Panels[PanelNum].Bevel in [pbRaised,pbLowered]) then begin
Canvas.Brush.Color := Color;
Canvas.FillRect(Rect(XLeft+1, Top+1, XLeft + PW-1, Top + Height - 1));
if Panels[PanelNum].Bevel = pbRaised then
begin
LeftTopColor:=clBtnHighlight;
RightBottomColor:=clBtnShadow;
end else begin
LeftTopColor:=clBtnShadow;
RightBottomColor:=clBtnHighlight;
end;
With Canvas Do Begin
Pen.Width:=1;
Pen.Color:=LeftTopColor;
MoveTo(XLeft,Top+Height-1);
LineTo(XLeft,Top);
LineTo(XLeft+PW-1,Top);
Pen.Color:=RightBottomColor;
LineTo(XLeft+PW-1,Top+Height);
MoveTo(XLeft+PW-1,Top+Height-1);
LineTo(XLeft,Top+Height-1);
End;
end else begin
Canvas.Brush.Color := Color;
Canvas.FillRect(Rect(XLeft, Top, XLeft + PW, Top + Height));
end;
End;
Procedure TStatusBar.DrawDivider(X : Integer);
Begin
Canvas.Pen.Width:=1;
Canvas.Pen.Color := clBtnHighlight;
Canvas.Line(X,Top,X,Top+Height-1);
Canvas.Pen.Color := clBtnShadow;
Canvas.Line(X+1,Top,X+1,Top+Height-1);
End;
Procedure TStatusBar.WMPaint(var Msg: TLMPaint);
var
I : Integer;
Style : TTextStyle;
R : TRect;
PW : Longint;
Begin
inherited WMPaint(Msg);
FillChar(Style, SizeOf(Style),0);
With Style do begin
Layout := tlCenter;
Alignment := taLeftJustify;
WordBreak := False;
SingleLine := True;
ShowPrefix := False;
end;
Canvas.Color := Color;
R := Rect(Left, Top, Left + ClientWidth, Top + ClientHeight);
if not SimplePanel then
Begin
Style.Opaque := True;
Style.Clipping := True;
if Panels.Count = 0 then exit;
For I := 0 to Panels.Count-1 do
Begin
if I = Panels.Count-1 then
PW := ClientWidth-R.Left
else
PW := Panels[I].Width;
R.Right := R.Left + PW;
DrawBevel(R.Left,I);
InflateRect(R, -2, -1);
Style.Alignment := Panels[I].Alignment;
Canvas.TextRect(R, 0, 0, Panels[i].Text, Style);
InflateRect(R, 2, 1);
//draw divider
if I < Panels.Count-1 then
DrawDivider(R.Right);
R.Left := R.Right;
end;
end
else begin
Style.Clipping := False;
Style.Opaque := False;
InflateRect(R, -2, -2);
Canvas.FillRect(R);
InflateRect(R, 2, 2);
Canvas.TextRect(R, 2, 0, SimpleText, Style);
end;
End;
{$ENDIF OldStatusBar}
// included by comctrls.pp

View File

@ -6105,18 +6105,20 @@ begin
ExpandItem,ExpandItem,0);
inc(CurPanelCount);
end;
CurPanelCount:=integer(g_list_length(PGtkBox(HBox)^.children));
//writeln('TgtkObject.UpdateStatusBarPanels B ',HexStr(Cardinal(StatusBar),8),' NewPanelCount=',NewPanelCount,' CurPanelCount=',CurPanelCount);
if CurPanelCount<>NewPanelCount then
RaiseGDBException('');
// remove unneeded panels
while CurPanelCount>NewPanelCount do begin
CurStatusPanelWidget:=PGtkBoxChild(
g_list_nth_data(PGtkBox(HBox)^.children,CurPanelCount-1))^.Widget;
DestroyConnectedWidget(CurStatusPanelWidget,true);
dec(CurPanelCount);
end;
CurPanelCount:=integer(g_list_length(PGtkBox(HBox)^.children));
//writeln('TgtkObject.UpdateStatusBarPanels B ',HexStr(Cardinal(StatusBar),8),' NewPanelCount=',NewPanelCount,' CurPanelCount=',CurPanelCount);
if CurPanelCount<>NewPanelCount then
RaiseGDBException('');
// set panel properties
ListItem:=PGTKBox(HBox)^.children;
i:=0;
@ -7994,10 +7996,12 @@ begin
csSpinEdit:
Begin
AnAdjustment:=gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(wHandle));
writeln('SetProperties ',AnAdjustment^.lower,' ',TSpinEdit(Sender).MinValue);
if (AnAdjustment^.lower<>TSpinEdit(Sender).MinValue)
or (AnAdjustment^.upper<>TSpinEdit(Sender).MaxValue) then
begin
AnAdjustment^.lower:=TSpinEdit(Sender).MinValue;
writeln('SetProperties ',AnAdjustment^.lower,' ',TSpinEdit(Sender).MinValue);
AnAdjustment^.upper:=TSpinEdit(Sender).MaxValue;
gtk_adjustment_changed(AnAdjustment);
end;
@ -9184,6 +9188,9 @@ end;
{ =============================================================================
$Log$
Revision 1.460 2004/02/02 19:48:01 mattias
fixed removing TStatusBar panels in gtk
Revision 1.459 2004/02/02 12:44:45 mattias
implemented interface constraints

View File

@ -55,6 +55,7 @@ type
procedure SetValue(Num : Single);
procedure SetClimbRate(num : Single);
procedure InitializeWnd; override;
procedure Loaded; override;
public
constructor Create(AOwner : TComponent); override;
destructor Destroy; override;