Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Redesigned GUI Layout

Fix file loading
Fix filtering
  • Loading branch information...
commit 6e4d30cb25d1d9f20b11eebd5ab4e3a141fceeed 1 parent bd17f10
@PhillipTaylor authored
View
15 SMSReader.mk
@@ -13,7 +13,7 @@ CurrentFileName :=
CurrentFilePath :=
CurrentFileFullPath :=
User :=phill
-Date :=04/01/12
+Date :=08/01/12
CodeLitePath :="/home/phill/.codelite"
LinkerName :=g++
ArchiveTool :=ar rcus
@@ -48,7 +48,7 @@ LibPath := "$(LibraryPathSwitch)."
## User defined environment variables
##
CodeLiteDir:=/usr/share/codelite
-Objects=$(IntermediateDirectory)/gui$(ObjectSuffix) $(IntermediateDirectory)/main$(ObjectSuffix) $(IntermediateDirectory)/gui_message_item$(ObjectSuffix) $(IntermediateDirectory)/sms_message$(ObjectSuffix)
+Objects=$(IntermediateDirectory)/gui$(ObjectSuffix) $(IntermediateDirectory)/main$(ObjectSuffix) $(IntermediateDirectory)/sms_message$(ObjectSuffix)
##
## Main Build Targets
@@ -84,14 +84,6 @@ $(IntermediateDirectory)/main$(DependSuffix): main.cpp
$(IntermediateDirectory)/main$(PreprocessSuffix): main.cpp
@$(CompilerName) $(CmpOptions) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/main$(PreprocessSuffix) "/home/phill/.codelite/SMSReader/main.cpp"
-$(IntermediateDirectory)/gui_message_item$(ObjectSuffix): gui_message_item.cpp $(IntermediateDirectory)/gui_message_item$(DependSuffix)
- $(CompilerName) $(SourceSwitch) "/home/phill/.codelite/SMSReader/gui_message_item.cpp" $(CmpOptions) $(ObjectSwitch)$(IntermediateDirectory)/gui_message_item$(ObjectSuffix) $(IncludePath)
-$(IntermediateDirectory)/gui_message_item$(DependSuffix): gui_message_item.cpp
- @$(CompilerName) $(CmpOptions) $(IncludePath) -MT$(IntermediateDirectory)/gui_message_item$(ObjectSuffix) -MF$(IntermediateDirectory)/gui_message_item$(DependSuffix) -MM "/home/phill/.codelite/SMSReader/gui_message_item.cpp"
-
-$(IntermediateDirectory)/gui_message_item$(PreprocessSuffix): gui_message_item.cpp
- @$(CompilerName) $(CmpOptions) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/gui_message_item$(PreprocessSuffix) "/home/phill/.codelite/SMSReader/gui_message_item.cpp"
-
$(IntermediateDirectory)/sms_message$(ObjectSuffix): sms_message.cpp $(IntermediateDirectory)/sms_message$(DependSuffix)
$(CompilerName) $(SourceSwitch) "/home/phill/.codelite/SMSReader/sms_message.cpp" $(CmpOptions) $(ObjectSwitch)$(IntermediateDirectory)/sms_message$(ObjectSuffix) $(IncludePath)
$(IntermediateDirectory)/sms_message$(DependSuffix): sms_message.cpp
@@ -112,9 +104,6 @@ clean:
$(RM) $(IntermediateDirectory)/main$(ObjectSuffix)
$(RM) $(IntermediateDirectory)/main$(DependSuffix)
$(RM) $(IntermediateDirectory)/main$(PreprocessSuffix)
- $(RM) $(IntermediateDirectory)/gui_message_item$(ObjectSuffix)
- $(RM) $(IntermediateDirectory)/gui_message_item$(DependSuffix)
- $(RM) $(IntermediateDirectory)/gui_message_item$(PreprocessSuffix)
$(RM) $(IntermediateDirectory)/sms_message$(ObjectSuffix)
$(RM) $(IntermediateDirectory)/sms_message$(DependSuffix)
$(RM) $(IntermediateDirectory)/sms_message$(PreprocessSuffix)
View
2  SMSReader.project
@@ -10,13 +10,11 @@
<VirtualDirectory Name="src">
<File Name="gui.cpp"/>
<File Name="main.cpp"/>
- <File Name="gui_message_item.cpp"/>
<File Name="sms_message.cpp"/>
</VirtualDirectory>
<VirtualDirectory Name="include">
<File Name="gui.h"/>
<File Name="main.h"/>
- <File Name="gui_message_item.h"/>
<File Name="sms_message.h"/>
</VirtualDirectory>
<VirtualDirectory Name="resources">
View
BIN  SMSReader.tags
Binary file not shown
View
42 SMSReader.workspace.session
@@ -1,36 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<Session Name="/home/phill/.codelite/SMSReader/SMSReader.workspace">
- <int Value="3" Name="m_selectedTab"/>
+ <int Value="1" Name="m_selectedTab"/>
<wxString Value="/home/phill/.codelite/SMSReader/SMSReader.workspace" Name="m_workspaceName"/>
<TabInfoArray Name="TabInfoArray">
<TabInfo>
+ <wxString Value="/home/phill/.codelite/SMSReader/sms_message.cpp" Name="FileName"/>
+ <int Value="0" Name="FirstVisibleLine"/>
+ <int Value="6" Name="CurrentLine"/>
+ <wxArrayString Name="Bookmarks"/>
+ </TabInfo>
+ <TabInfo>
<wxString Value="/home/phill/.codelite/SMSReader/main.cpp" Name="FileName"/>
- <int Value="90" Name="FirstVisibleLine"/>
- <int Value="130" Name="CurrentLine"/>
+ <int Value="60" Name="FirstVisibleLine"/>
+ <int Value="78" Name="CurrentLine"/>
<wxArrayString Name="Bookmarks"/>
</TabInfo>
<TabInfo>
<wxString Value="/home/phill/.codelite/SMSReader/gui.h" Name="FileName"/>
- <int Value="9" Name="FirstVisibleLine"/>
- <int Value="10" Name="CurrentLine"/>
+ <int Value="0" Name="FirstVisibleLine"/>
+ <int Value="11" Name="CurrentLine"/>
<wxArrayString Name="Bookmarks"/>
</TabInfo>
<TabInfo>
<wxString Value="/home/phill/.codelite/SMSReader/main.h" Name="FileName"/>
- <int Value="32" Name="FirstVisibleLine"/>
- <int Value="57" Name="CurrentLine"/>
+ <int Value="1" Name="FirstVisibleLine"/>
+ <int Value="59" Name="CurrentLine"/>
<wxArrayString Name="Bookmarks"/>
</TabInfo>
<TabInfo>
<wxString Value="/home/phill/.codelite/SMSReader/gui.cpp" Name="FileName"/>
- <int Value="4" Name="FirstVisibleLine"/>
- <int Value="11" Name="CurrentLine"/>
- <wxArrayString Name="Bookmarks"/>
- </TabInfo>
- <TabInfo>
- <wxString Value="/home/phill/.codelite/SMSReader/gui_message_item.h" Name="FileName"/>
- <int Value="0" Name="FirstVisibleLine"/>
- <int Value="0" Name="CurrentLine"/>
+ <int Value="25" Name="FirstVisibleLine"/>
+ <int Value="47" Name="CurrentLine"/>
<wxArrayString Name="Bookmarks"/>
</TabInfo>
<TabInfo>
@@ -39,18 +39,6 @@
<int Value="20" Name="CurrentLine"/>
<wxArrayString Name="Bookmarks"/>
</TabInfo>
- <TabInfo>
- <wxString Value="/home/phill/.codelite/SMSReader/sms_message.cpp" Name="FileName"/>
- <int Value="0" Name="FirstVisibleLine"/>
- <int Value="6" Name="CurrentLine"/>
- <wxArrayString Name="Bookmarks"/>
- </TabInfo>
- <TabInfo>
- <wxString Value="/home/phill/.codelite/SMSReader/gui_message_item.cpp" Name="FileName"/>
- <int Value="0" Name="FirstVisibleLine"/>
- <int Value="8" Name="CurrentLine"/>
- <wxArrayString Name="Bookmarks"/>
- </TabInfo>
</TabInfoArray>
<SerializedObject Name="m_breakpoints">
<long Value="0" Name="Count"/>
View
90 gui.cpp
@@ -12,6 +12,7 @@
MainFrameBase::MainFrameBase( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
+ this->SetTitle(wxT("Phills SMS Reader"));
//Menu Bar stuff.
m_menuBar = new wxMenuBar( 0 );
@@ -27,60 +28,26 @@ MainFrameBase::MainFrameBase( wxWindow* parent, wxWindowID id, const wxString& t
m_menuBar->Append( m_menuFile, _("&File") );
this->SetMenuBar( m_menuBar );
+
+ wxBoxSizer* mainSizer = new wxBoxSizer(wxVERTICAL);
+ this->SetSizer(mainSizer);
- //main sizer for whole interface
- wxBoxSizer* mainSizer = new wxBoxSizer( wxVERTICAL );
+ wxBoxSizer* filterSizer = new wxBoxSizer(wxHORIZONTAL);
+ mainSizer->Add(filterSizer, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5);
- this->SetSizer( mainSizer );
-
- // Filter box section
- wxStaticText* filterLabel = new wxStaticText(this, wxID_ANY, wxT("Filter by Sender:"));
-
- m_filter = new wxComboBox(
- this,
- wxID_ANY,
- wxT(""),
- wxDefaultPosition,
- wxDefaultSize,
- 0,
- NULL,
- wxCB_DROPDOWN|wxCB_READONLY
- );
-
- wxBoxSizer* filterSizer = new wxBoxSizer( wxHORIZONTAL );
- filterSizer->Add(filterLabel);
- filterSizer->Add(m_filter);
- mainSizer->Add(filterSizer);
-
- // List of Messages section
- m_scrWin = new wxScrolledWindow(
- this,
- wxID_ANY
- );
-
- m_listSizer = new wxBoxSizer(wxVERTICAL);
- m_scrWin->SetSizer(m_listSizer);
- mainSizer->Add(m_scrWin, wxEXPAND);
-
- //example msg
- SMSMessage* exampleMessage = new SMSMessage(
- wxT("+44 07950 322 789"),
- wxT("2011-13-07 13:22"),
- wxT("Yo mate, what's up?")
- );
+ wxStaticText* lblFilter = new wxStaticText( this, wxID_STATIC, _("Filter Sender: "), wxDefaultPosition, wxDefaultSize, 0 );
+ filterSizer->Add(lblFilter, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
- for (int i = 0; i < 6; i++) {
- AddSMSMessagePanel(*exampleMessage);
- }
-
- //wxSize minimum(300,500);
+ wxArrayString filterList;
+ cboFilter = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, filterList, 0 );
+ filterSizer->Add(cboFilter, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
+
+ wxArrayString messageList;
+ lstMessages = new wxSimpleHtmlListBox( this, wxID_ANY, wxDefaultPosition, wxSize(400, 300), messageList, wxHLB_DEFAULT_STYLE );
+ mainSizer->Add(lstMessages, 1, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5);
- m_scrWin->FitInside();
- //m_scrWin->SetMinSize(minimum);
- //m_listSizer->SetMinSize(minimum);
- //m_scrWin->EnableScrolling(true, true);
- //m_scrWin->SetScrollRate(1,1);
- m_scrWin->SetScrollRate(5, 5);
+ lstMessages->SetBackgroundColour(this->GetBackgroundColour());
+ AddSMSMessage(SMSMessage(wxT(""),wxT(""),wxT("")));
this->Layout();
m_statusBar = this->CreateStatusBar( 1, wxST_SIZEGRIP, wxID_ANY );
@@ -91,6 +58,7 @@ MainFrameBase::MainFrameBase( wxWindow* parent, wxWindowID id, const wxString& t
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( MainFrameBase::OnCloseFrame ) );
this->Connect( menuFileOpen->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnFileOpen ) );
this->Connect( menuFileExit->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnExitClick ) );
+ this->Connect( cboFilter->GetId(), wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( MainFrameBase::OnChangeFilter ) );
}
MainFrameBase::~MainFrameBase()
@@ -101,10 +69,24 @@ MainFrameBase::~MainFrameBase()
}
void MainFrameBase::ClearAll() {
- m_listSizer->Clear(true);
+ lstMessages->Clear();
}
-void MainFrameBase::AddSMSMessagePanel(const SMSMessage& message) {
- GUIMessageItem* gmi = new GUIMessageItem(m_scrWin, wxID_ANY, message); //object inherits from wxPanel
- m_listSizer->Add(gmi);
+void MainFrameBase::AddSMSMessage(const SMSMessage& message) {
+
+ wxString t;
+ wxString open1 = wxString(wxT("<div align=\"left\" color=\"#ff00aa\">"));
+ wxString open2 = wxString(wxT("</div><div align=\"right\" color=\"#ffbbcc\""));
+ wxString open3 = wxString(wxT("</div><br><div>"));
+ wxString open4 = wxString(wxT("</div>"));
+
+ t = open1;
+ t += message.GetSender();
+ t += open2;
+ t += message.GetSentTime();
+ t += open3;
+ t += message.GetMessage();
+ t += open4;
+
+ lstMessages->Insert(t, lstMessages->GetCount());
}
View
12 gui.h
@@ -9,7 +9,7 @@
#define __gui__
#include <wx/wx.h>
-#include "gui_message_item.h"
+#include <wx/htmllbox.h>
#include "sms_message.h"
/*
@@ -49,16 +49,16 @@ class MainFrameBase : public wxFrame
wxMenuBar* m_menuBar;
wxMenu* m_menuFile;
wxStatusBar* m_statusBar;
- wxComboBox* m_filter;
- wxScrolledWindow* m_scrWin;
- wxBoxSizer* m_listSizer;
-
+ wxSimpleHtmlListBox* lstMessages;
+ wxChoice* cboFilter;
+
// Virtual event handlers, overide them in your derived class
virtual void OnCloseFrame( wxCloseEvent& event ) { event.Skip(); }
virtual void OnExitClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnFileOpen( wxCommandEvent& event ) { event.Skip(); }
+ virtual void OnChangeFilter( wxCommandEvent& event) { event.Skip(); }
virtual void ClearAll();
- virtual void AddSMSMessagePanel(const SMSMessage& message);
+ virtual void AddSMSMessage(const SMSMessage& message);
public:
View
39 main.cpp
@@ -75,11 +75,10 @@ void MainFrame::OnFileOpen(wxCommandEvent& event)
void MainFrame::LoadFile(const wxString& filename) {
- const char *d = filename.mb_str();
- TiXmlDocument doc("/home/phill/30-12-2011-093329.xml");
+ const string& fn = string(filename.mb_str());
+ TiXmlDocument doc(fn);
if (doc.LoadFile()) {
- //m_statusBar->SetStatusText(wxT("Loading: ") + filename);
TiXmlHandle hDoc(&doc);
TiXmlElement* pElem;
@@ -90,15 +89,9 @@ void MainFrame::LoadFile(const wxString& filename) {
m_statusBar->SetStatusText(wxT("No root node"));
return;
}
-
- //wxString s(pElem->Value(), wxConvUTF8);
- /*for (TiXmlAttribute* rootAttr = pRootNode->FirstAttribute(); rootAttr != NULL, rootAttr->Next()) {
-
- if (rootAttr->Name() == "count")
-
- } */
-
+
allMessages.clear();
+ vector<wxString> uniqueList;
for (pElem = pRootNode->FirstChildElement(); pElem != NULL; pElem = pElem->NextSiblingElement()) {
@@ -112,9 +105,16 @@ void MainFrame::LoadFile(const wxString& filename) {
shared_ptr<SMSMessage> msg(new SMSMessage(wxsAddr, wxsSentTime, wxsMessageBody));
allMessages.push_back(msg);
- }
+
+ const wxString& t = msg->GetSender();
- m_filter->Clear();
+ if (find(uniqueList.begin(), uniqueList.end(), t) == uniqueList.end()) {
+ cboFilter->Insert(t, cboFilter->GetCount());
+ uniqueList.push_back(t);
+ }
+
+ }
+
UpdateFilters();
} else {
@@ -127,7 +127,18 @@ void MainFrame::UpdateFilters() {
ClearAll();
+ int selected = cboFilter->GetSelection();
+
for (vector<shared_ptr<SMSMessage> >::const_iterator msg = allMessages.begin(); msg != allMessages.end(); msg++) {
- AddSMSMessagePanel(**msg);
+
+ if (selected == -1 || allMessages[selected]->GetSender() == (*msg)->GetSender()) {
+ AddSMSMessage(**msg);
+ }
+
}
+
+}
+
+void MainFrame::OnChangeFilter(wxCommandEvent& event) {
+ UpdateFilters();
}
View
2  main.h
@@ -20,6 +20,7 @@
#include <boost/shared_ptr.hpp>
#include <wx/wx.h>
#include <tinyxml.h>
+#include <algorithm>
// gui classes generated by wxFormBuilder
#include "sms_message.h"
#include "gui.h"
@@ -53,6 +54,7 @@ class MainFrame : public MainFrameBase
virtual void OnExitClick( wxCommandEvent& event );
virtual void OnFileOpen( wxCommandEvent& event );
virtual void LoadFile( const wxString& filename );
+ virtual void OnChangeFilter( wxCommandEvent& event);
private:
std::vector<boost::shared_ptr<SMSMessage> > allMessages;
Please sign in to comment.
Something went wrong with that request. Please try again.