diff options
author | Graeme Geldenhuys <graemeg@gmail.com> | 2013-04-27 18:42:48 +0100 |
---|---|---|
committer | Graeme Geldenhuys <graemeg@gmail.com> | 2013-04-29 12:08:23 +0100 |
commit | 0d4e42a4f03deb86e7718c084bc7317490b0c825 (patch) | |
tree | bf270300ba9810f2928449260b1731086050421a /examples/apps/debugserver | |
parent | 15e40c9ea4544a1a74f571f495e00d4bd122c76c (diff) | |
download | fpGUI-0d4e42a4f03deb86e7718c084bc7317490b0c825.tar.xz |
debugserver: Now support LiveView messages.
LiveView messages don't appear in the normal log message window. Instead
they appear in a separate non-scrolling grid where the previous values
get replaced with the new values.
Diffstat (limited to 'examples/apps/debugserver')
-rw-r--r-- | examples/apps/debugserver/fpgDebugServer.lpi | 7 | ||||
-rw-r--r-- | examples/apps/debugserver/frm_main.pas | 53 |
2 files changed, 52 insertions, 8 deletions
diff --git a/examples/apps/debugserver/fpgDebugServer.lpi b/examples/apps/debugserver/fpgDebugServer.lpi index f26f35ee..582e7494 100644 --- a/examples/apps/debugserver/fpgDebugServer.lpi +++ b/examples/apps/debugserver/fpgDebugServer.lpi @@ -38,7 +38,7 @@ <PackageName Value="fpgui_toolkit"/> </Item1> </RequiredPackages> - <Units Count="2"> + <Units Count="3"> <Unit0> <Filename Value="fpgDebugServer.lpr"/> <IsPartOfProject Value="True"/> @@ -49,6 +49,11 @@ <IsPartOfProject Value="True"/> <UnitName Value="frm_main"/> </Unit1> + <Unit2> + <Filename Value="fra_liveview.pas"/> + <IsPartOfProject Value="True"/> + <UnitName Value="fra_liveview"/> + </Unit2> </Units> </ProjectOptions> <CompilerOptions> diff --git a/examples/apps/debugserver/frm_main.pas b/examples/apps/debugserver/frm_main.pas index 89543763..8ae9fe33 100644 --- a/examples/apps/debugserver/frm_main.pas +++ b/examples/apps/debugserver/frm_main.pas @@ -118,6 +118,7 @@ type procedure CheckDebugMessages; procedure ReadDebugMessage; procedure ShowDebugMessage(const AMsg: TDebugmessage); + procedure ShowLiveViewMessage(const AMsg: TDebugmessage); procedure ShowMessageWindow; procedure miPauseClicked(Sender: TObject); procedure miFileQuit(Sender: TObject); @@ -148,6 +149,7 @@ uses dateutils ,fpg_dialogs ,fpg_constants + ,fpg_dbugintf ; @@ -186,12 +188,13 @@ begin ADefaultDrawing := False; try i := StrToInt(grdMessages.Cells[ACol, ARow]); + { TODO: This needs improving. We need to somehow referce TDebugLevel instead } case i of - -1: img := fpgImages.GetImage('dbs.state.stop'); - 0: img := fpgImages.GetImage('dbs.state.info'); - 1: img := fpgImages.GetImage('dbs.state.warning'); - 2: img := fpgImages.GetImage('dbs.state.error'); - 3: img := fpgImages.GetImage('dbs.state.identify'); + 0: img := fpgImages.GetImage('dbs.state.stop'); + 1: img := fpgImages.GetImage('dbs.state.info'); + 2: img := fpgImages.GetImage('dbs.state.warning'); + 3: img := fpgImages.GetImage('dbs.state.error'); + 4: img := fpgImages.GetImage('dbs.state.identify'); end; dx := (grdMessages.ColumnWidth[ACol] - 16) div 2; grdMessages.Canvas.DrawImage(ARect.Left + dx, ARect.Top {+ y}, img); @@ -279,9 +282,14 @@ var Msg: TDebugMessage; begin FIPCSrv.MsgData.Seek(0, soFromBeginning); - ReadDebugMessageFromStream(FIPCSrv.MsgData, MSg); + ReadDebugMessageFromStream(FIPCSrv.MsgData, Msg); if not FPaused then - ShowDebugMessage(Msg) + begin + if Msg.MsgType = Ord(dlLive) then + ShowLiveViewMessage(Msg) + else + ShowDebugMessage(Msg); + end else Inc(FDiscarded); end; @@ -310,6 +318,36 @@ begin ShowMessageWindow; end; +procedure TMainForm.ShowLiveViewMessage(const AMsg: TDebugmessage); +var + r: integer; + lFound: Boolean; +begin + if not Assigned(FLiveViewFrame) then + Exit; + lFound := False; + FLiveViewFrame.Grid.BeginUpdate; + for r := 0 to FLiveViewFrame.Grid.RowCount-1 do + begin + if FLiveViewFrame.Grid.Cells[0, r] = AMsg.MsgTitle then + begin + lFound := True; + Break; + end; + end; + if lFound then + begin + FLiveViewFrame.Grid.Cells[1, r] := AMsg.Msg; + end + else + begin + FLiveViewFrame.Grid.RowCount := FLiveViewFrame.Grid.RowCount + 1; + FLiveViewFrame.Grid.Cells[0, FLiveViewFrame.Grid.RowCount-1] := AMsg.MsgTitle; + FLiveViewFrame.Grid.Cells[1, FLiveViewFrame.Grid.RowCount-1] := AMsg.Msg; + end; + FLiveViewFrame.Grid.EndUpdate; +end; + procedure TMainForm.ShowMessageWindow; begin if not Visible then @@ -404,6 +442,7 @@ begin WindowTitle := 'fpGUI''s Debug Server'; Hint := ''; ShowHint := True; + WindowPosition := wpScreenCenter; MainMenu := TfpgMenuBar.Create(self); with MainMenu do |