improved and activated new statusbar

git-svn-id: trunk@5053 -
This commit is contained in:
mattias 2004-01-12 13:43:12 +00:00
parent fd4254a45d
commit a9c328fd76
6 changed files with 182 additions and 70 deletions

View File

@ -4027,6 +4027,10 @@ end;
Procedure TSourceNotebook.UpdateStatusBar;
var
tempEditor : TSourceEditor;
PanelFilename: String;
PanelCharMode: string;
PanelXY: string;
PanelFileMode: string;
begin
if not Visible then exit;
TempEditor := GetActiveSE;
@ -4034,36 +4038,46 @@ begin
if (TempEditor.EditorComponent.CaretY<>TempEditor.ErrorLine)
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]);
end else begin
Statusbar.SimplePanel:=false;
Statusbar.Panels[3].Text := TempEditor.Filename;
PanelFilename:=TempEditor.Filename;
If TempEditor.Modified then
StatusBar.Panels[1].Text := ueModified
PanelFileMode := ueModified
else
StatusBar.Panels[1].Text := '';
PanelFileMode := '';
If TempEditor.ReadOnly then
if StatusBar.Panels[1].Text <> '' then
StatusBar.Panels[1].Text := Format(lisUEReadOnly, [StatusBar.Panels[1
if PanelFileMode <> '' then
PanelFileMode := Format(lisUEReadOnly, [StatusBar.Panels[1
].Text])
else
StatusBar.Panels[1].Text := uepReadonly;
PanelFileMode := uepReadonly;
Statusbar.Panels[0].Text :=
Format(' %6d:%4d',[TempEditor.CurrentCursorYLine,TempEditor.CurrentCursorXLine]);
PanelXY := Format(' %6d:%4d',
[TempEditor.CurrentCursorYLine,TempEditor.CurrentCursorXLine]);
if GetActiveSE.InsertMode then
Statusbar.Panels[2].Text := uepIns
PanelCharMode := uepIns
else
Statusbar.Panels[2].Text := uepOvr;
PanelCharMode := uepOvr;
Statusbar.Panels[0].Text := PanelXY;
StatusBar.Panels[1].Text := PanelFileMode;
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

@ -34,7 +34,6 @@ unit ComCtrls;
{$mode objfpc}
{$H+}
interface
uses
@ -103,8 +102,13 @@ type
TStatusBar = Class(TWinControl)
private
{$IFNDEF NewStatusBar}
{$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;
@ -112,20 +116,26 @@ type
procedure SetPanels(Value: TStatusPanels);
procedure SetSimpleText(const Value : String);
procedure SetSimplePanel(Value : Boolean);
{$IFNDEF NewStatusBar}
{$IFDEF OldStatusBar}
Procedure WMPaint(var Msg: TLMPaint); message LM_PAINT;
Procedure DrawDivider(X : Integer);
Procedure DrawBevel(xLeft, PanelNum : Integer);
{$ENDIF}
{$IFDEF NewStatusBar}
{$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 NewStatusBar}
{$IFNDEF OldStatusBar}
procedure BeginUpdate;
procedure EndUpdate;
function UpdatingStatusBar: boolean;
{$ELSE}
procedure GetPanelRect(PanelIndex: integer; var ARect: TRect);
public
property Canvas: TCanvas read FCanvas;
@ -134,7 +144,8 @@ type
property Panels: TStatusPanels read FPanels write SetPanels;
property SimpleText: String read FSimpleText write SetSimpleText;
property SimplePanel: Boolean read FSimplePanel write SetSimplePanel default True;
property Visible;
property Visible default true;
property Color default clBtnFace;
end;
@ -1955,6 +1966,9 @@ end.
{ =============================================================================
$Log$
Revision 1.102 2004/01/12 13:43:12 mattias
improved and activated new statusbar
Revision 1.101 2004/01/12 08:36:33 micha
statusbar interface dependent reimplementation (from vincent)

View File

@ -566,11 +566,13 @@ begin
Result := false;
end;
procedure TInterfaceBase.StatusBarPanelUpdate(StatusBar: TObject; PanelIndex: integer);
procedure TInterfaceBase.StatusBarPanelUpdate(StatusBar: TObject;
PanelIndex: integer);
begin
end;
procedure TInterfaceBase.StatusBarSetText(StatusBar: TObject; PanelIndex: integer);
procedure TInterfaceBase.StatusBarSetText(StatusBar: TObject;
PanelIndex: integer);
begin
end;
@ -590,6 +592,9 @@ end;
{ =============================================================================
$Log$
Revision 1.13 2004/01/12 13:43:12 mattias
improved and activated new statusbar
Revision 1.12 2004/01/12 08:36:34 micha
statusbar interface dependent reimplementation (from vincent)

View File

@ -24,7 +24,7 @@ begin
ControlStyle := [csCaptureMouse, csClickEvents, csDoubleClicks, csOpaque];
FSimplePanel := True;
FPanels := TStatusPanels.Create(Self);
{$IFNDEF NewStatusBar}
{$IFDEF OldStatusBar}
FCanvas := TControlCanvas.Create;
TControlCanvas(FCanvas).Control := Self;
{$ENDIF}
@ -43,10 +43,10 @@ begin
if FSimpleText <> value then
begin
FSimpleText := Value;
{$IFDEF NewStatusBar}
if HandleAllocated and FSimplePanel then StatusBarSetText(Self,0);
{$ELSE}
{$IFDEF OldStatusBar}
Invalidate;
{$ELSE}
if HandleAllocated and FSimplePanel then StatusBarSetText(Self,0);
{$ENDIF}
end;
end;
@ -56,10 +56,10 @@ Begin
if FSimplePanel <> Value then
Begin
FSimplePanel := Value;
{$IFDEF NewStatusBar}
if HandleAllocated then StatusBarUpdate(Self);
{$ELSE}
{$IFDEF OldStatusBar}
Invalidate;
{$ELSE}
UpdateHandleObject(-1);
{$ENDIF}
end;
End;
@ -69,26 +69,105 @@ begin
FPanels.Assign(Value);
end;
{------------------------------------------------------------------------------}
{ TStatusBar Destructor }
{------------------------------------------------------------------------------}
destructor TStatusBar.Destroy;
begin
FreeThenNil(FPanels);
{$IFNDEF NewStatusBar}
{$IFDEF OldStatusBar}
FreeThenNil(FCanvas);
{$ENDIF}
inherited Destroy;
end;
{$IFDEF NewStatusBar}
{$IFNDEF OldStatusBar}
procedure TStatusBar.CreateWnd;
begin
inherited CreateWnd;
StatusBarUpdate(Self);
if FHandleObjectNeedsUpdate then
UpdateHandleObject(FHandleUpdatePanelIndex);
end;
{$ENDIF}
procedure TStatusBar.DestroyWnd;
begin
inherited DestroyWnd;
FHandlePanelCount:=0;
FHandleObjectNeedsUpdate:=false;
end;
procedure TStatusBar.Loaded;
begin
inherited Loaded;
if FHandleObjectNeedsUpdate then
UpdateHandleObject(FHandleUpdatePanelIndex);
end;
procedure TStatusBar.UpdateHandleObject(PanelIndex: integer);
begin
if (not HandleAllocated) or (csDestroying in ComponentState)
or ((PanelIndex>0) and SimplePanel) then exit;
if (csLoading in ComponentState) or (FUpdateLock>0) then begin
//writeln('TStatusBar.UpdateHandleObject Caching FHandleObjectNeedsUpdate=',FHandleObjectNeedsUpdate,' FHandleUpdatePanelIndex=',FHandleUpdatePanelIndex,' ',PanelIndex);
if FHandleObjectNeedsUpdate then begin
// combine multiple updates
if (FHandleUpdatePanelIndex>=0)
and (FHandleUpdatePanelIndex<>PanelIndex) then
// at least 2 different panels need update => update all
FHandleUpdatePanelIndex:=-1 // update all
else
FHandleUpdatePanelIndex:=PanelIndex;
end else begin
// start an update sequence
FHandleObjectNeedsUpdate:=true;
FHandleUpdatePanelIndex:=PanelIndex;
end;
exit;
end;
//writeln('TStatusBar.UpdateHandleObject A FHandlePanelCount=',FHandlePanelCount,' PanelIndex=',PanelIndex,' Panels.Count=',Panels.Count,' ',SimplePanel);
if FHandlePanelCount>PanelIndex then begin
// update one panel
StatusBarPanelUpdate(Self,PanelIndex);
end else begin
// update all panels
StatusBarUpdate(Self);
if SimplePanel then
FHandlePanelCount:=1
else
FHandlePanelCount:=Panels.Count;
end;
FHandleObjectNeedsUpdate:=false;
end;
procedure TStatusBar.BeginUpdate;
begin
inc(FUpdateLock);
if FUpdateLock=1 then
Panels.BeginUpdate;
end;
procedure TStatusBar.EndUpdate;
begin
if FUpdateLock<=0 then RaiseGDBException('TStatusBar.EndUpdate');
if FUpdateLock=1 then begin
// end update in Panels before decreasing FUpdateLock, so that
// multiple changes of Panels will be combined
Panels.EndUpdate;
end;
dec(FUpdateLock);
if (FUpdateLock=0) then begin
if FHandleObjectNeedsUpdate then
UpdateHandleObject(FHandleUpdatePanelIndex);
end;
end;
function TStatusBar.UpdatingStatusBar: boolean;
begin
Result:=FUpdateLock>0;
end;
{$ENDIF not OldStatusBar}
{------------------------------------------------------------------------------
procedure TStatusBar.InvalidatePanel(PanelIndex: integer;
@ -96,16 +175,16 @@ end;
------------------------------------------------------------------------------}
procedure TStatusBar.InvalidatePanel(PanelIndex: integer;
PanelParts: TPanelParts);
{$IFNDEF NewStatusBar}
{$IFDEF OldtatusBar}
var
PanelRect, TextRect: TRect;
{$ENDIF}
begin
if (PanelParts=[]) or (not HandleAllocated) or (csLoading in ComponentState)
then exit;
{$IFDEF NewStatusBar}
StatusBarPanelUpdate(Self,PanelIndex);
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
@ -125,7 +204,7 @@ begin
{$ENDIF}
end;
{$IFNDEF NewStatusBar}
{$IFDEF OldStatusBar}
{------------------------------------------------------------------------------
procedure TStatusBar.GetPanelRect(PanelIndex: integer; var ARect: TRect);
------------------------------------------------------------------------------}
@ -254,6 +333,6 @@ Begin
Canvas.TextRect(R, 2, 0, SimpleText, Style);
end;
End;
{$ENDIF}
{$ENDIF OldStatusBar}
// included by comctrls.pp

View File

@ -35,9 +35,10 @@
Returns:
------------------------------------------------------------------------------}
function TGTKObject.GetAcceleratorString(const AVKey: Byte; const AShiftState: TShiftState): String;
function TGTKObject.GetAcceleratorString(const AVKey: Byte;
const AShiftState: TShiftState): String;
begin
// Your code here
Result:='';
end;
{------------------------------------------------------------------------------
@ -244,13 +245,17 @@ var
AStatusBar: TStatusBar;
HBox: PGtkWidget;
StatusPanelWidget: PGtkWidget;
BoxChild: PGtkBoxChild;
begin
//writeln('TGTKObject.StatusBarPanelUpdate ',HexStr(Cardinal(StatusBar),8),' Index=',Index);
AStatusBar:=StatusBar as TStatusBar;
if Index>=0 then begin
// update one
HBox:=PGtkWidget(AStatusBar.Handle);
StatusPanelWidget:=PGtkBoxChild(
g_list_nth_data(PGtkBox(HBox)^.children,Index))^.Widget;
BoxChild:=PGtkBoxChild(g_list_nth_data(PGtkBox(HBox)^.children,Index));
if BoxChild=nil then
RaiseGDBException('TGTKObject.StatusBarPanelUpdate Index out of bounds');
StatusPanelWidget:=BoxChild^.Widget;
UpdateStatusBarPanel(StatusBar,Index,StatusPanelWidget);
end else begin
// update all
@ -267,20 +272,8 @@ end;
------------------------------------------------------------------------------}
procedure TGTKObject.StatusBarSetText(StatusBar: TObject; PanelIndex: integer);
var
AStatusBar: TStatusBar;
HBox: PGtkWidget;
StatusPanelWidget: PGtkWidget;
begin
AStatusBar := StatusBar as TStatusBar;
if AStatusBar.SimplePanel then
UpdateStatusBarPanels(StatusBar,PGtkWidget(AStatusBar.Handle))
else begin
HBox:=PGtkWidget(AStatusBar.Handle);
StatusPanelWidget:=PGtkBoxChild(
g_list_nth_data(PGtkBox(HBox)^.children,PanelIndex))^.Widget;
UpdateStatusBarPanel(StatusBar,PanelIndex,StatusPanelWidget);
end;
StatusBarPanelUpdate(StatusBar,PanelIndex);
end;
{------------------------------------------------------------------------------
@ -291,6 +284,7 @@ end;
------------------------------------------------------------------------------}
procedure TGTKObject.StatusBarUpdate(StatusBar: TObject);
begin
//writeln('TGTKObject.StatusBarUpdate ',HexStr(Cardinal(StatusBar),8));
UpdateStatusBarPanels(StatusBar,PGtkWidget((StatusBar as TStatusBar).Handle));
end;
@ -299,6 +293,9 @@ end;
{ =============================================================================
$Log$
Revision 1.11 2004/01/12 13:43:12 mattias
improved and activated new statusbar
Revision 1.10 2004/01/12 08:36:34 micha
statusbar interface dependent reimplementation (from vincent)

View File

@ -3561,7 +3561,7 @@ end;
may be nice to use it with different panels.
------------------------------------------------------------------------------}
procedure TgtkObject.SetText(Child, Data: Pointer);
{$IFNDEF NewStatusBar}
{$IFDEF OldStatusBar}
var
num : Integer;
{$ENDIF}
@ -3569,8 +3569,7 @@ begin
case PLMSetControlText(Data)^.fCompStyle of
csStatusBar :
begin
{$IFDEF NewStatusBar}
{$ELSE}
{$IFDEF OldStatusBar}
num := gtk_statusbar_get_context_id(PGTKStatusBar(Child),
PChar(inttostr(PLMSetControlText(Data)^.panel)));
gtk_statusbar_push(PGTKStatusBar(Child),num,
@ -5555,17 +5554,12 @@ end;
Create a TStatusBar widget set
------------------------------------------------------------------------------}
function TgtkObject.CreateStatusBar(StatusBar: TObject): PGtkWidget;
{$IFDEF NewStatusBar}
var
HBox: PGtkWidget;
{$ENDIF}
begin
{$IFDEF NewStatusBar}
HBox:=gtk_hbox_new(false,0);
UpdateStatusBarPanels(StatusBar,HBox);
Result:=HBox;
{$ELSE}
{$IFDEF OldStatusBar}
Result:=gtk_statusbar_new;
{$ELSE}
Result:=gtk_hbox_new(false,0);
UpdateStatusBarPanels(StatusBar,Result);
{$ENDIF}
end;
@ -5601,10 +5595,12 @@ var
i: Integer;
ExpandItem: boolean;
begin
//writeln('TgtkObject.UpdateStatusBarPanels');
//writeln('TgtkObject.UpdateStatusBarPanels ',HexStr(Cardinal(StatusBar),8));
AStatusBar:=StatusBar as TStatusBar;
HBox:=PGtkWidget(StatusBarWidget);
if (not GtkWidgetIsA(StatusBarWidget,GTK_HBOX_TYPE)) then
RaiseGDBException('');
// create needed panels
CurPanelCount:=integer(g_list_length(PGtkBox(HBox)^.children));
@ -5620,6 +5616,9 @@ begin
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
@ -5660,6 +5659,7 @@ var
NewShadowType: TGtkShadowType;
NewJustification: TGtkJustification;
begin
//writeln('TgtkObject.UpdateStatusBarPanel ',HexStr(Cardinal(StatusBar),8),' Index=',Index);
AStatusBar:=StatusBar as TStatusBar;
CurPanel:=nil;
@ -8678,6 +8678,9 @@ end;
{ =============================================================================
$Log$
Revision 1.450 2004/01/12 13:43:12 mattias
improved and activated new statusbar
Revision 1.449 2004/01/10 22:34:20 mattias
started double buffering for gtk intf