menuBar->Append( mnuCreate, wxT("Create") );
+ mnuWindow = new wxMenu();
+ menuBar->Append( mnuWindow, wxT("Window") );
+
mnuHelp = new wxMenu();
wxMenuItem* mnuHelpShow;
mnuHelpShow = new wxMenuItem( mnuHelp, wxID_HELP, wxString( wxT("Show Help...") ) + wxT('\t') + wxT("F1"), wxEmptyString, wxITEM_NORMAL );
this->Centre( wxBOTH );
// Connect Events
+ this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( frmEventEditorADT::CloseWindow ) );
this->Connect( mnuEventSave->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( frmEventEditorADT::SaveContact ) );
this->Connect( mnuEventSaveNew->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( frmEventEditorADT::SaveNewContact ) );
this->Connect( mnuEventClose->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( frmEventEditorADT::CloseWindow ) );
this->Connect( mnuEditCut->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( frmEventEditorADT::CutText ) );
this->Connect( mnuEditCopy->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( frmEventEditorADT::CopyText ) );
this->Connect( mnuEditPaste->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( frmEventEditorADT::PasteText ) );
+ cmbCalendar->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( frmEventEditorADT::ProcessCalendarControl ), NULL, this );
+ txtEventName->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( frmEventEditorADT::ProcessEventName ), NULL, this );
}
frmEventEditorADT::~frmEventEditorADT()
{
// Disconnect Events
+ this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( frmEventEditorADT::CloseWindow ) );
this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( frmEventEditorADT::SaveContact ) );
this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( frmEventEditorADT::SaveNewContact ) );
this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( frmEventEditorADT::CloseWindow ) );
this->Disconnect( wxID_CUT, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( frmEventEditorADT::CutText ) );
this->Disconnect( wxID_COPY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( frmEventEditorADT::CopyText ) );
this->Disconnect( wxID_PASTE, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( frmEventEditorADT::PasteText ) );
+ cmbCalendar->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( frmEventEditorADT::ProcessCalendarControl ), NULL, this );
+ txtEventName->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( frmEventEditorADT::ProcessEventName ), NULL, this );
}
-// AppXesitaCalendar.cpp - Xestia Calendar application form code header
+// AppXesitaCalendar.h - Xestia Calendar application form code header
//
// (c) 2016-2017 Xestia Software Development.
//
wxMenuBar* menuBar;
wxMenu* mnuManage;
wxMenu* mnuCreate;
+ wxMenu* mnuWindow;
wxMenu* mnuHelp;
wxBoxSizer* szrMain;
wxTextCtrl* m_textCtrl20;
// Virtual event handlers, overide them in your derived class
+ virtual void CloseWindow( wxCloseEvent& event ) { event.Skip(); }
virtual void SaveContact( wxCommandEvent& event ) { event.Skip(); }
virtual void SaveNewContact( wxCommandEvent& event ) { event.Skip(); }
virtual void CloseWindow( wxCommandEvent& event ) { event.Skip(); }
virtual void CutText( wxCommandEvent& event ) { event.Skip(); }
virtual void CopyText( wxCommandEvent& event ) { event.Skip(); }
virtual void PasteText( wxCommandEvent& event ) { event.Skip(); }
+ virtual void ProcessCalendarControl( wxCommandEvent& event ) { event.Skip(); }
+ virtual void ProcessEventName( wxCommandEvent& event ) { event.Skip(); }
public:
CPP=g++
STRIP=strip
-BMCO_CPPFLAGS=`xml2-config --cflags` `wx-config --cxxflags` -std=c++11 -Os -I./common -ggdb
-CPPFLAGS=`xml2-config --cflags` `wx-config --cxxflags` -std=c++11 -Os -I./common -ggdb
+BMCO_CPPFLAGS=`xml2-config --cflags` `wx-config --cxxflags` -std=c++11 -I./common -ggdb
+CPPFLAGS=`xml2-config --cflags` `wx-config --cxxflags` -std=c++11 -I./common -ggdb
BMCO_CPPLIBS=`wx-config --libs` `curl-config --libs` -lxml2
CPPLIBS=`wx-config --libs` `curl-config --libs` -lxml2 -Llibraries -lCalendarDataStorage -lsqlite3
CDSLIBS=-lsqlite3
COMMONOBJS=common/monthviewgen.o common/file.o common/text.o \
common/uuid.o common/preferences.o common/dirs.o common/defaults.o \
common/random.o common/svrblist.o
-FORM_MAINOBJS=forms/main/frmMain.o
+FORM_MAINOBJS=forms/main/frmMain.o forms/main/frmMain-Window.o
FORM_UPDATEOBJS=forms/update/frmUpdate.o
FORM_EDITACCOUNTOBJS=forms/editaccount/frmEditAccount.o
FORM_NEWACCOUNTOBJS=forms/newaccount/frmNewAccount.o
COMMONOBJS=common/monthviewgen.o common/file.o common/text.o \
common/uuid.o common/preferences.o common/dirs.o common/defaults.o \
common/random.o common/svrblist.o
-FORM_MAINOBJS=forms/main/frmMain.o
+FORM_MAINOBJS=forms/main/frmMain.o forms/main/frmMain-Window.o
FORM_UPDATEOBJS=forms/update/frmUpdate.o
FORM_EDITACCOUNTOBJS=forms/editaccount/frmEditAccount.o
FORM_NEWACCOUNTOBJS=forms/newaccount/frmNewAccount.o
DECLARE_EVENT_TYPE(XCMAIN_ADDEVENT, wxID_ANY)
DECLARE_EVENT_TYPE(XCMAIN_UPDATEEVENT, wxID_ANY)
+DEFINE_EVENT_TYPE(XCMAIN_ADDWINDOWINFO)
+DEFINE_EVENT_TYPE(XCMAIN_UPDATEWINDOWINFO)
+DEFINE_EVENT_TYPE(XCMAIN_DELETEWINDOWINFO)
+
+DECLARE_EVENT_TYPE(XCMAIN_ADDWINDOWINFO, wxID_ANY)
+DECLARE_EVENT_TYPE(XCMAIN_UPDATEWINDOWINFO, wxID_ANY)
+DECLARE_EVENT_TYPE(XCMAIN_DELETEWINDOWINFO, wxID_ANY)
+
DEFINE_EVENT_TYPE(XCCALENDARDAY_UPDATEICONS)
DEFINE_EVENT_TYPE(XCCALENDARDAY_DESELECTOTHERENTRIES)
DEFINE_EVENT_TYPE(XCCALENDARDAY_DESELECTALLENTRIES)
#define ID_ADDENTRY 7018
#define ID_UPDATEENTRY 7019
#define ID_UPDATECOLOUR 7020
+#define ID_ADDWINDOW 7021
+#define ID_UPDATEWINDOW 7022
+#define ID_DELETEWINDOW 7023
+
+struct WindowData{
+
+ int DataType;
+ void *WindowPointer;
+ int WindowID;
+
+};
#endif
\ No newline at end of file
calendarID = eventInfo.calendarID;
+ // Set the calendar combination box to the name.
+
+ string combinedName = dataStorage->GetCalendar(calendarID).accountName;
+ combinedName += " : ";
+ combinedName += dataStorage->GetCalendar(eventInfo.calendarID).calendarName;
+
// Load the calendar info.
+ cmbCalendar->SetSelection(cmbCalendar->FindString(combinedName));
cmbCalendar->Show(false);
lblCalendar->Show(false);
eventData.LoadFile(eventFilePath);
// TODO: Set the duration data.
+
+ } else {
+
+ // Setup the date and time with some default values (today's date and time).
+
+ SetDefaultDateTime();
- return;
}
-
- // Setup the date and time with some default values (today's date and time).
-
- SetDefaultDateTime();
+ // Enable window updating and update window name.
+
+ UpdateWindowName();
+ enableUpdates = true;
+
}
void frmEventEditor::SetEditMode(bool editMode){
szrDetails->Layout();
szrList->Layout();
-
-
}
void frmEventEditor::SaveContact(){
}
-void frmEventEditor::CloseWindow(wxCommandEvent &event){
+void frmEventEditor::CloseWindow(wxCommandEvent &event)
+{
this->Close();
}
+void frmEventEditor::CloseWindow(wxCloseEvent &event)
+{
+
+ WindowData *deleteWindowData = new WindowData;
+
+ deleteWindowData->DataType = 1;
+ deleteWindowData->WindowPointer = (void*)this;
+ deleteWindowData->WindowID = windowID;
+
+ // Delete the window from the window list.
+
+ wxCommandEvent deleteEvent(XCMAIN_DELETEWINDOWINFO);
+ deleteEvent.SetId(ID_DELETEWINDOW);
+ deleteEvent.SetClientData(deleteWindowData);
+ wxPostEvent(this->GetParent(), deleteEvent);
+
+ this->Destroy();
+
+}
+
bool frmEventEditor::ProcessEvent(wxEvent& event)
{
txtEndTime->SetValue((wxString)formattedTime);
+}
+
+void frmEventEditor::SetWindowMenuItemID(int windowID)
+{
+
+ this->windowID = windowID;
+
+}
+
+void frmEventEditor::ProcessCalendarControl(wxCommandEvent &event)
+{
+
+ UpdateWindowName();
+
+}
+
+void frmEventEditor::ProcessEventName(wxCommandEvent &event)
+{
+
+ UpdateWindowName();
+
+}
+
+void frmEventEditor::UpdateWindowName()
+{
+
+ // Generate the window title.
+
+ string windowTitle;
+
+ if (cmbCalendar->GetSelection() == -1)
+ {
+ windowTitle += "(calendar not selected)";
+ }
+ else
+ {
+ windowTitle += cmbCalendar->GetStringSelection().ToStdString();
+ }
+
+ if (txtEventName->IsEmpty())
+ {
+ windowTitle += " - ";
+ windowTitle += "(unamed event)";
+ }
+ else
+ {
+ windowTitle += " - ";
+ windowTitle += txtEventName->GetValue().ToStdString();
+ }
+
+ SetTitle(windowTitle);
+
+ // Check if post window title updating is enabled before
+ // going any further.
+
+ if (enableUpdates == false)
+ {
+ return;
+ }
+
+ WindowData *updateWindowData = new WindowData;
+
+ updateWindowData->DataType = 1;
+ updateWindowData->WindowPointer = (void*)this;
+ updateWindowData->WindowID = windowID;
+
+ // Delete the window from the window list.
+
+ wxCommandEvent updateEvent(XCMAIN_UPDATEWINDOWINFO);
+ updateEvent.SetId(ID_UPDATEWINDOW);
+ updateEvent.SetClientData(updateWindowData);
+ wxPostEvent(this->GetParent(), updateEvent);
+
}
\ No newline at end of file
CalendarEventObject eventData;
vector<int> calendarIDList;
bool editMode = false;
+ bool enableUpdates = false;
+ int accountID = 0;
int eventID = 0;
int calendarID = 0;
+ int windowID = 0;
string eventFilePath;
void SaveContact();
XCALPreferences *preferences;
void SetDefaultDateTime();
+ void UpdateWindowName();
protected:
void SaveContact(wxCommandEvent &event);
void SaveNewContact(wxCommandEvent &event);
void CloseWindow(wxCommandEvent &event);
+ void CloseWindow(wxCloseEvent &event);
void CutText(wxCommandEvent &event);
void CopyText(wxCommandEvent &event);
void PasteText(wxCommandEvent &event);
bool ProcessEvent(wxEvent& event);
+ void ProcessCalendarControl(wxCommandEvent &event);
+ void ProcessEventName(wxCommandEvent &event);
public:
/** Constructor */
frmEventEditor( wxWindow* parent );
void SetupForm(CalendarDataStorage *dataStorage, XCALPreferences *preferences);
void SetEditMode(bool editMode);
void SetEventID(int eventID);
+ void SetWindowMenuItemID(int windowID);
//// end generated class members
};
--- /dev/null
+// frmMain-Window.h - frmMain form window functions.
+//
+// (c) 2017 Xestia Software Development.
+//
+// This file is part of Xestia Calendar.
+//
+// Xestia Calendar is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by the
+// Free Software Foundation, version 3 of the license.
+//
+// Xestia Calendar is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with Xestia Calendar. If not, see <http://www.gnu.org/licenses/>
+
+#include "frmMain.h"
+
+void frmMain::WindowAdd( wxCommandEvent &event ){
+
+ // Add a window to the window list.
+
+ WindowData *receivedWindowData = (WindowData*)event.GetClientData();
+
+ size_t pos;
+
+ wxMenuItem *mnuNewItem = new wxMenuItem(NULL, receivedWindowData->WindowID, wxT("Event Window #") + wxString::Format(wxT("%i"), receivedWindowData->WindowID), wxEmptyString, wxITEM_NORMAL, NULL);
+ mnuNewItem->SetId(receivedWindowData->WindowID);
+ mnuWindow->Append(mnuNewItem);
+ this->Connect(mnuNewItem->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(frmMain::ShowEventWindow));
+
+ frmEventEditor *frmEventEditorPtr = static_cast<frmEventEditor*>(receivedWindowData->WindowPointer);
+ wxString windowTitle = frmEventEditorPtr->GetTitle();
+ mnuNewItem->SetItemLabel(windowTitle);
+
+ WindowListPointersMenu.insert(std::make_pair(receivedWindowData->WindowID, mnuNewItem));
+ WindowListPointers.insert(std::make_pair(receivedWindowData->WindowID, receivedWindowData->WindowPointer));
+ WindowListType.insert(std::make_pair(receivedWindowData->WindowID, 0));
+
+ delete receivedWindowData;
+ receivedWindowData = NULL;
+
+}
+
+void frmMain::WindowUpdate( wxCommandEvent &event ){
+
+ // Add a window to the window list.
+
+ WindowData *receivedWindowData = (WindowData*)event.GetClientData();
+
+ size_t pos;
+
+ frmEventEditor *frmEventEditorPtr = static_cast<frmEventEditor*>(receivedWindowData->WindowPointer);
+
+ wxString windowTitle = frmEventEditorPtr->GetTitle();
+
+ std::map<int, wxMenuItem*>::iterator MenuIter = WindowListPointersMenu.find(receivedWindowData->WindowID);
+
+ MenuIter->second->SetItemLabel(windowTitle);
+
+ delete receivedWindowData;
+ receivedWindowData = NULL;
+
+}
+
+void frmMain::WindowDelete( wxCommandEvent &event ){
+
+ // Delete the window from the window list.
+
+ WindowData *receivedWindowData = (WindowData*)event.GetClientData();
+
+ size_t pos;
+
+ std::map<int, wxMenuItem*>::iterator menuIter = WindowListPointersMenu.find(receivedWindowData->WindowID);
+
+ mnuWindow->Destroy(menuIter->second);
+
+ WindowListPointersMenu.erase(receivedWindowData->WindowID);
+ WindowListPointers.erase(receivedWindowData->WindowID);
+ WindowListType.erase(receivedWindowData->WindowID);
+
+ delete receivedWindowData;
+ receivedWindowData = NULL;
+
+}
+
+void frmMain::ShowEventWindow( wxCommandEvent &event ){
+
+ // Show a contact window from the window list.
+
+ std::map<int, void*>::iterator WindowIter = WindowListPointers.find(event.GetId());
+
+ frmEventEditor *frmEventEditorPtr = static_cast<frmEventEditor*>(WindowIter->second);
+
+ frmEventEditorPtr->Show();
+ frmEventEditorPtr->Raise();
+
+}
+}
\ No newline at end of file
-// frmMain.h - frmMain form functions header.
+// frmMain.h - frmMain form functions
//
// (c) 2016-2017 Xestia Software Development.
//
Connect(ID_UPDATEENTRY, XCMAIN_UPDATEEVENT, wxCommandEventHandler(frmMain::UpdateEvent));
Connect(ID_EDITEVENT, XCMAIN_EDITEVENT, wxCommandEventHandler(frmMain::EditEvent));
+ Connect(ID_ADDWINDOW, XCMAIN_ADDWINDOWINFO, wxCommandEventHandler(frmMain::WindowAdd));
+ Connect(ID_UPDATEWINDOW, XCMAIN_UPDATEWINDOWINFO, wxCommandEventHandler(frmMain::WindowUpdate));
+ Connect(ID_DELETEWINDOW, XCMAIN_DELETEWINDOWINFO, wxCommandEventHandler(frmMain::WindowDelete));
+
}
void frmMain::QuitApp( wxCloseEvent& event )
frmEventEditor *frameNewEvent = new frmEventEditor ( this );
frameNewEvent->SetupForm(&calendarData, preferences);
+ frameNewEvent->SetWindowMenuItemID(++WindowMenuItemID);
+
+ // Add the window to the window list.
+
+ WindowData *newWindowData = new WindowData;
+
+ newWindowData->DataType = 1;
+ newWindowData->WindowPointer = (void*)frameNewEvent;
+ newWindowData->WindowID = WindowMenuItemID;
+
+ wxCommandEvent addevent(XCMAIN_ADDWINDOWINFO);
+ addevent.SetId(ID_ADDWINDOW);
+ addevent.SetClientData(newWindowData);
+ wxPostEvent(this, addevent);
+
frameNewEvent->Show();
}
frmEventEditor *frameEditEvent = new frmEventEditor ( this );
frameEditEvent->SetEventID(event.GetInt());
frameEditEvent->SetEditMode(true);
+ frameEditEvent->SetWindowMenuItemID(++WindowMenuItemID);
frameEditEvent->SetupForm(&calendarData, preferences);
+
+ // Add the window to the window list.
+
+ WindowData *newWindowData = new WindowData;
+
+ newWindowData->DataType = 1;
+ newWindowData->WindowPointer = (void*)frameEditEvent;
+ newWindowData->WindowID = WindowMenuItemID;
+
+ wxCommandEvent addevent(XCMAIN_ADDWINDOWINFO);
+ addevent.SetId(ID_ADDWINDOW);
+ addevent.SetClientData(newWindowData);
+ wxPostEvent(this, addevent);
+
+ // Setup the form and display it.
+
frameEditEvent->Show();
}
CalendarDataStorage calendarData;
ColourUpdateProperties updateColourData;
bool reloadAccounts = false;
+ std::map<int,wxMenuItem*> WindowListPointersMenu;
+ std::map<int,void*> WindowListPointers;
+ std::map<int,int> WindowListType;
+ int WindowMenuItemID = 0;
protected:
void QuitApp( wxCloseEvent& event );
void CloseWindow( wxCommandEvent& event );
void ShowHelp( wxCommandEvent& event );
+ void WindowAdd( wxCommandEvent& event );
+ void WindowUpdate( wxCommandEvent& event );
+ void WindowDelete( wxCommandEvent& event );
+ void ShowEventWindow( wxCommandEvent &event );
public:
/** Constructor */
frmMain( wxWindow* parent );