|
From: <ma...@us...> - 2003-12-29 09:52:41
|
Update of /cvsroot/sharedaemon/ui-wx/src
In directory sc8-pr-cvs1:/tmp/cvs-serv19070
Modified Files:
ServerWnd.cpp ServerWnd.h
Log Message:
Workaround to implement log scrolling in GTK
Index: ServerWnd.cpp
===================================================================
RCS file: /cvsroot/sharedaemon/ui-wx/src/ServerWnd.cpp,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -d -r1.55 -r1.56
--- ServerWnd.cpp 29 Dec 2003 09:25:25 -0000 1.55
+++ ServerWnd.cpp 29 Dec 2003 09:52:38 -0000 1.56
@@ -41,20 +41,22 @@
EVT_BUTTON(ID_ADDTOLIST, CServerWnd::AddNewServer)
EVT_BUTTON(ID_UPDATE, CServerWnd::UpdateFromURL)
EVT_SIZE(CServerWnd::OnSize)
+ EVT_TEXT(ID_LOG, CServerWnd::OnAddLogLine)
END_EVENT_TABLE()
-/*
- * Constructor for server window. Loads the server dialog and sets LogBook
+/*
+ * Constructor for server window. Loads the server dialog and sets LogBook
* images.
*/
-CServerWnd::CServerWnd(
- wxWindow *parent, wxWindowID id, const wxPoint &position,
+CServerWnd::CServerWnd(
+ wxWindow *parent, wxWindowID id, const wxPoint &position,
const wxSize& size, long style )
: wxPanel( parent, id, position, size, style ) {
bool show_sidebar;
+ log_line_count = 0;
CreateControls();
-
+
/**
* Read SideBar value from config object, and if it
* returns false, toggle (hide) the sidebar.
@@ -241,12 +243,14 @@
wxDefaultSize, 0, wxT("log")
);
s_log->Add(log_img, 0, wxALL, 5);
- wxStaticText *log_txt = new wxStaticText(bottom_panel, -1, _("Log"));
+ wxStaticText *log_txt = new wxStaticText(
+ bottom_panel, ID_LOG, _("Log")
+ );
s_log->Add(log_txt, 0, wxALL, 5);
s_bottom->Add(s_log);
wxTextCtrl *txt_logs = new wxTextCtrl(
bottom_panel, ID_LOG, wxEmptyString, wxDefaultPosition,
- wxDefaultSize,
+ wxDefaultSize,
wxTE_MULTILINE|wxTE_READONLY|wxTE_RICH|wxTE_AUTO_URL
);
new wxLogChain(new wxLogTextCtrl(txt_logs));
@@ -623,4 +627,19 @@
}
return item0;
+}
+
+/*************************************************************** OnAddLogLine */
+/* Only needed on GTK to keep last line in log always visible. We remember */
+/* the number of lines in the control in @log_line_count and show the correct */
+/* line each time. Note that we can't use wxTextCtrl::GetNumberOfLines(), */
+/* since on GTK, it calculates the number of lines by actually counting them, */
+/* thus could get really cpu-hungry if there are large amount of lines here. */
+/******************************************************************************/
+void CServerWnd::OnAddLogLine(wxCommandEvent &event) {
+#ifndef __WXMSW__
+ GetLog()->ShowPosition(log_line_count);
+ log_line_count++;
+#endif
+ event.Skip();
}
Index: ServerWnd.h
===================================================================
RCS file: /cvsroot/sharedaemon/ui-wx/src/ServerWnd.h,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- ServerWnd.h 29 Dec 2003 09:25:25 -0000 1.33
+++ ServerWnd.h 29 Dec 2003 09:52:38 -0000 1.34
@@ -59,6 +59,7 @@
DECLARE_EVENT_TABLE()
/* Member event handlers */
void ToggleSidebar(wxCommandEvent &event);
+ void OnAddLogLine(wxCommandEvent &event);
/* Member function declarations */
void AddNewServer();
@@ -86,6 +87,8 @@
/* Sidebar and its panels */
wxPanel *sidebar;
+ long log_line_count;
+
/* Splitter window and its panels */
wxPanel *top_panel, *bottom_panel;
wxSplitterWindow *splatter;
@@ -94,6 +97,9 @@
wxFlexGridSizer *mainsizer;
/* Getters for dialog controls */
+ wxTextCtrl* GetLog() {
+ return (wxTextCtrl*) FindWindow( ID_LOG );
+ }
wxButton* GetUpdate() {
return (wxButton*) FindWindow( ID_UPDATE );
}
|