-
Notifications
You must be signed in to change notification settings - Fork 4
/
log.cpp
107 lines (74 loc) · 2.19 KB
/
log.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/**
* -----------------------------------------------------
* File log.cpp
* Authors David Ordnung, Impact
* License GPLv3
* Web http://dordnung.de, http://gugyclan.eu
* -----------------------------------------------------
*
* Copyright (C) 2013-2017 David Ordnung, Impact
*
* This program 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, either version 3 of the License, or
* any later version.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>
*/
// c++
#include <sstream>
#include <ctime>
// Include Project
#include "log.h"
#include "main.h"
#include "taskbar.h"
#include "calladmin-client.h"
// Log Panel
LogPanel* logPanel = NULL;
// Create Log Panel
LogPanel::LogPanel(wxNotebook* note) : wxPanel(note, wxID_ANY)
{
// Set Log Panel
logPanel = this;
// Border and Center
wxSizerFlags flags;
// Border and Centre
flags.Border(wxALL, 10);
flags.Centre();
// Create Box
wxSizer* const sizerTop = new wxBoxSizer(wxVERTICAL);
logBox = new wxListBox(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_HSCROLL | wxLB_SINGLE);
logBox->SetFont(wxFont(12, FONT_FAMILY, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL));
// Add Log Box
sizerTop->Add(logBox, 1, wxEXPAND);
// Auto Size
SetSizerAndFit(sizerTop, true);
}
// Add Action to the logBox
void LogPanel::addLog(wxString log)
{
if (logBox != NULL)
{
logBox->SetSelection(logBox->Append(wxString::FromUTF8(log)));
}
}
void LogAction(wxString action)
{
// Add the new Log to the Log box
char buffer[80];
time_t t = time(0);
struct tm* now = localtime(&t);
// But first we need a Time
strftime(buffer, sizeof(buffer), "%c", now);
// Add the log
if (logPanel != NULL)
{
logPanel->addLog((wxString)buffer + " - " + action);
}
}