|
From: <ma...@us...> - 2003-12-06 00:18:43
|
Update of /cvsroot/sharedaemon/ui-wx/src
In directory sc8-pr-cvs1:/tmp/cvs-serv4913
Modified Files:
SBPanel.cpp SBPanel.h ServerWnd.cpp
Log Message:
Sidebar speed/memory optimizations
Index: SBPanel.cpp
===================================================================
RCS file: /cvsroot/sharedaemon/ui-wx/src/SBPanel.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- SBPanel.cpp 21 Nov 2003 02:55:55 -0000 1.3
+++ SBPanel.cpp 6 Dec 2003 00:18:37 -0000 1.4
@@ -45,9 +45,9 @@
wxWindow *parent, wxWindowID id, const
wxString &title, const wxString &name
) : wxPanel(
- parent, id, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, name)
+ parent, id, wxDefaultPosition, wxDefaultSize,
+ wxTAB_TRAVERSAL, name)
{
-
wxStaticBox *box = new wxStaticBox(this, -1, wxT(""));
mainsizer = new wxStaticBoxSizer(box, wxVERTICAL);
@@ -55,19 +55,24 @@
this, -1, title, wxDefaultPosition, wxDefaultSize, 0
);
headerbtn->SetFont( wxFont( 12, wxROMAN, wxNORMAL, wxBOLD ) );
- mainsizer->Add( headerbtn, 0, wxGROW, 5 );
+ mainsizer->Add( headerbtn, 0, wxGROW|wxADJUST_MINSIZE, 5 );
SetAutoLayout(true);
SetSizer(mainsizer);
mainsizer->Fit(this);
mainsizer->SetSizeHints(this);
-
+
+ shown = false;
}
+/**
+ * Destructor. Save content displayment bool into config object under
+ * /ParentName/ThisName
+ */
CSBPanel::~CSBPanel() {
m_config->Write(
wxT("/")+GetParent()->GetName()+wxT("/")+GetName(),
- content->IsShown()
+ shown
);
}
@@ -78,56 +83,50 @@
* Layout() as neccesery.
*/
void CSBPanel::Toggle(wxCommandEvent &event) {
-
if (event.GetId() != headerbtn->GetId()) {
event.Skip();
return;
}
- if (content->IsShown()) {
+ if (shown) {
mainsizer->Hide(content);
- content->Hide();
+ shown = false;
} else {
mainsizer->Show(content);
- content->Show();
+ shown = true;
}
- mainsizer->SetMinSize(GetParent()->GetSize().GetWidth()-5, -1);
- mainsizer->Fit(this);
-
- GetParent()->GetSizer()->Layout();
- ::wxGetTopLevelParent(this)->Layout();
- GetParent()->Refresh();
+ GetParent()->Layout();
}
/**
- * This method adds contents (a panel) into the section. We store
- * the pointer to the content panel locally for easier access.
+ * This method adds contents (a sizer) into the section. We store
+ * the pointer to the content sizer locally for easier access.
* If there is any existing content in CSBPAnel, it is removed.
* And last, read from config under section /ParentWindowName/SectionName
* if the new section should be shown or not (default: true)
*/
-void CSBPanel::SetContent(wxPanel *data) {
- bool shown;
+void CSBPanel::SetContent(wxSizer *data) {
+ bool tmp;
- if (content) {
+ if (shown) {
mainsizer->Remove(content);
}
content = data;
mainsizer->Add(content, 0, wxGROW|wxALL, 5);
- mainsizer->Fit(this);
mainsizer->Layout();
+ shown = true;
m_config->Read(
- wxT("/")+GetParent()->GetName()+wxT("/")+GetName(), &shown, true
+ wxT("/")+GetParent()->GetName()+wxT("/")+GetName(), &tmp, true
);
- if (!shown) {
- /**
- * We create an empty event with headerbtn ID and send it to
- * Toggle, since Toggle doesn't accept events with any other IDs
- */
+ /**
+ * If config instructs us to NOT show the contents, call Toggle()
+ * method with nullevent .
+ */
+ if (!tmp) {
wxCommandEvent nullevent;
nullevent.SetId(headerbtn->GetId());
Toggle(nullevent);
Index: SBPanel.h
===================================================================
RCS file: /cvsroot/sharedaemon/ui-wx/src/SBPanel.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- SBPanel.h 20 Nov 2003 01:27:26 -0000 1.2
+++ SBPanel.h 6 Dec 2003 00:18:37 -0000 1.3
@@ -49,13 +49,13 @@
);
virtual ~CSBPanel();
- void SetContent(wxPanel *data);
+ void SetContent(wxSizer *data);
void Toggle(wxCommandEvent &event);
private:
DECLARE_EVENT_TABLE();
wxStaticBoxSizer *mainsizer;
- wxPanel *content;
+ wxSizer *content;
wxButton *headerbtn;
bool shown;
};
Index: ServerWnd.cpp
===================================================================
RCS file: /cvsroot/sharedaemon/ui-wx/src/ServerWnd.cpp,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- ServerWnd.cpp 30 Nov 2003 23:07:27 -0000 1.43
+++ ServerWnd.cpp 6 Dec 2003 00:18:37 -0000 1.44
@@ -212,16 +212,13 @@
/**
* Create new CSBPanel object which provides framework for
- * opening/closing the section. Then create a new panel to store
- * the contents of the section, and attach it to CSBPanel.
- * Finally, append the CSBPanel to our sidebar panel.
+ * opening/closing the section, set its content and add to
+ * sidebar.
*/
CSBPanel *addserver = new CSBPanel(
sidebar, -1, _("Add new server"), wxT("SideBar_AddServer")
);
- wxPanel *addserver_cnt = new wxPanel(addserver, -1);
- AddServerPanel(addserver_cnt);
- addserver->SetContent(addserver_cnt);
+ addserver->SetContent(AddServerPanel(addserver, false, false));
/* Need to use border 0 on wxMSW to have correct layout */
#ifdef __WXMSW__
@@ -233,33 +230,25 @@
CSBPanel *updatelist = new CSBPanel(
sidebar, -1, _("Update from URL"), wxT("SideBar_UpdateServer")
);
- wxPanel *updatelist_cnt = new wxPanel(updatelist, -1);
- UpdatePanel(updatelist_cnt);
- updatelist->SetContent(updatelist_cnt);
+ updatelist->SetContent(UpdatePanel(updatelist, false, false));
sbmain->Add(updatelist, 0, wxGROW|wxALL|wxADJUST_MINSIZE, 0);
CSBPanel *serversettings = new CSBPanel(
sidebar, -1, _("Server settings"), wxT("SideBar_ServerSettings")
);
- wxPanel *serversettings_cnt = new wxPanel(serversettings, -1);
- SettingsPanel(serversettings_cnt);
- serversettings->SetContent(serversettings_cnt);
+ serversettings->SetContent(SettingsPanel(serversettings, false, false));
sbmain->Add(serversettings, 0, wxGROW|wxALL|wxADJUST_MINSIZE, 0);
CSBPanel *portsettings = new CSBPanel(
sidebar, -1, _("Port settings"), wxT("SideBar_PortSettings")
);
- wxPanel *portsettings_cnt = new wxPanel(portsettings, -1);
- PortSettingsPanel(portsettings_cnt);
- portsettings->SetContent(portsettings_cnt);
+ portsettings->SetContent(PortSettingsPanel(portsettings, false, false));
sbmain->Add(portsettings, 0, wxGROW|wxALL|wxADJUST_MINSIZE, 0);
CSBPanel *logoptions = new CSBPanel(
sidebar, -1, _("Log options"), wxT("SideBar_LoggingOptions")
);
- wxPanel *logoptions_cnt = new wxPanel(logoptions, -1);
- LogOptionsPanel(logoptions_cnt);
- logoptions->SetContent(logoptions_cnt);
+ logoptions->SetContent(LogOptionsPanel(logoptions, false, false));
sbmain->Add(logoptions, 0, wxGROW|wxALL|wxADJUST_MINSIZE, 0);
/**
|