125
void wxStatusBarEx::AddChild(int field, wxWindow* pChild, int cx)
127
t_statbar_child data;
128
data.field = GetFieldIndex(field);
129
data.pChild = pChild;
132
m_children.push_back(data);
137
void wxStatusBarEx::RemoveChild(int field, wxWindow* pChild)
139
field = GetFieldIndex(field);
141
for (std::list<struct t_statbar_child>::iterator iter = m_children.begin(); iter != m_children.end(); iter++)
143
if (pChild != iter->pChild)
146
if (field != iter->field)
149
m_children.erase(iter);
154
void wxStatusBarEx::PositionChild(const struct wxStatusBarEx::t_statbar_child& data)
156
const wxSize size = data.pChild->GetSize();
159
GetFieldRect(data.field, rect);
161
data.pChild->SetSize(rect.x + data.cx, rect.GetTop() + (rect.GetHeight() - size.x + 1) / 2, -1, -1);
164
127
void wxStatusBarEx::OnSize(wxSizeEvent& event)
168
int wxStatusBarEx::GetGripperWidth()
170
#if defined(__WXMSW__)
171
return m_pParent->IsMaximized() ? 0 : 6;
172
#elif defined(__WXGTK__)
181
BEGIN_EVENT_TABLE(CWidgetsStatusBar, wxStatusBarEx)
182
EVT_SIZE(CWidgetsStatusBar::OnSize)
185
CWidgetsStatusBar::CWidgetsStatusBar(wxTopLevelWindow* parent)
186
: wxStatusBarEx(parent)
190
CWidgetsStatusBar::~CWidgetsStatusBar()
194
void CWidgetsStatusBar::OnSize(wxSizeEvent& event)
196
wxStatusBarEx::OnSize(event);
198
for (int i = 0; i < GetFieldsCount(); i++)
202
if (GetLayoutDirection() != wxLayout_RightToLeft)
207
void CWidgetsStatusBar::AddChild(int field, int idx, wxWindow* pChild)
209
field = GetFieldIndex(field);
211
t_statbar_child data;
213
data.pChild = pChild;
215
m_children[idx] = data;
217
PositionChildren(field);
220
void CWidgetsStatusBar::RemoveChild(int idx)
222
std::map<int, struct t_statbar_child>::iterator iter = m_children.find(idx);
223
if (iter != m_children.end())
225
int field = iter->second.field;
226
m_children.erase(iter);
227
PositionChildren(field);
231
void CWidgetsStatusBar::PositionChildren(int field)
234
GetFieldRect(field, rect);
238
if (field + 1 == GetFieldsCount())
240
rect.SetWidth(m_columnWidths[field]);
241
offset += 5 + GetGripperWidth();
244
for (std::map<int, struct t_statbar_child>::iterator iter = m_children.begin(); iter != m_children.end(); iter++)
246
if (iter->second.field != field)
249
const wxSize size = iter->second.pChild->GetSize();
250
int position = rect.GetRight() - size.x - offset;
252
iter->second.pChild->SetSize(position, rect.GetTop() + (rect.GetHeight() - size.y + 1) / 2, -1, -1);
254
offset += size.x + 3;
214
259
class wxStaticBitmapEx : public wxStaticBitmap
271
316
EVT_RIGHT_UP(CIndicator::OnRightMouseUp)
272
317
END_EVENT_TABLE()
319
BEGIN_EVENT_TABLE(CStatusBar, CWidgetsStatusBar)
320
EVT_MENU(XRCID("ID_SPEEDLIMITCONTEXT_ENABLE"), CStatusBar::OnSpeedLimitsEnable)
321
EVT_MENU(XRCID("ID_SPEEDLIMITCONTEXT_CONFIGURE"), CStatusBar::OnSpeedLimitsConfigure)
274
324
CStatusBar::CStatusBar(wxTopLevelWindow* pParent)
275
: wxStatusBarEx(pParent)
325
: CWidgetsStatusBar(pParent), CStateEventHandler(0)
328
RegisterOption(OPTION_SPEEDLIMIT_ENABLE);
329
RegisterOption(OPTION_SPEEDLIMIT_INBOUND);
330
RegisterOption(OPTION_SPEEDLIMIT_OUTBOUND);
333
RegisterOption(OPTION_SIZE_FORMAT);
334
RegisterOption(OPTION_SIZE_USETHOUSANDSEP);
335
RegisterOption(OPTION_SIZE_DECIMALPLACES);
337
RegisterOption(OPTION_ASCIIBINARY);
339
CContextManager::Get()->RegisterHandler(this, STATECHANGE_SERVER, true, false);
340
CContextManager::Get()->RegisterHandler(this, STATECHANGE_CHANGEDCONTEXT, false, false);
277
342
m_pDataTypeIndicator = 0;
278
343
m_pEncryptionIndicator = 0;
280
m_pSftpEncryptionInfo = 0;
344
m_pSpeedLimitsIndicator = 0;
283
347
m_hasUnknownFiles = false;
286
350
SetFieldsCount(count);
287
351
int array[count];
288
for (int i = 0; i < count - 2; i++)
289
array[i] = wxSB_FLAT;
290
array[count - 2] = wxSB_NORMAL;
291
array[count - 1] = wxSB_FLAT;
352
array[0] = wxSB_FLAT;
353
array[1] = wxSB_NORMAL;
354
array[2] = wxSB_FLAT;
292
355
SetStatusStyles(count, array);
294
357
SetStatusWidths(count, statbarWidths);
296
359
UpdateSizeFormat();
361
UpdateSpeedLimitsIcon();
299
366
CStatusBar::~CStatusBar()
301
delete m_pCertificate;
302
delete m_pSftpEncryptionInfo;
305
// Defined in LocalListView.cpp
306
extern wxString FormatSize(const wxLongLong& size, bool add_bytes_suffix, int format, bool thousands_separator, int num_decimal_places);
308
370
void CStatusBar::DisplayQueueSize(wxLongLong totalSize, bool hasUnknown)
310
372
m_size = totalSize;
319
381
wxString queueSize = wxString::Format(_("Queue: %s%s"), hasUnknown ? _T(">") : _T(""),
320
FormatSize(totalSize, true, m_sizeFormat, m_sizeFormatThousandsSep, m_sizeFormatDecimalPlaces).c_str());
382
CSizeFormat::Format(totalSize, true, m_sizeFormat, m_sizeFormatThousandsSep, m_sizeFormatDecimalPlaces).c_str());
322
384
SetStatusText(queueSize, FIELD_QUEUESIZE);
325
void CStatusBar::DisplayDataType(const CServer* const pServer)
387
void CStatusBar::DisplayDataType()
389
const CServer* pServer = 0;
390
const CState* pState = CContextManager::Get()->GetCurrentContext();
392
pServer = pState->GetServer();
327
394
if (!pServer || !CServer::ProtocolHasDataTypeConcept(pServer->GetProtocol()))
329
396
if (m_pDataTypeIndicator)
331
RemoveChild(-4, m_pDataTypeIndicator);
398
RemoveChild(widget_datatype);
332
399
m_pDataTypeIndicator->Destroy();
333
400
m_pDataTypeIndicator = 0;
335
if (m_pEncryptionIndicator)
337
RemoveChild(-4, m_pEncryptionIndicator);
338
AddChild(-4, m_pEncryptionIndicator, 22);
396
451
s.IncTo(dc.GetTextExtent(wxString::Format(_("Queue: %s MiB"), tmp.c_str())));
398
SetFieldWidth(-2, s.x + 10);
453
SetFieldWidth(FIELD_QUEUESIZE, s.x + 10);
401
void CStatusBar::DisplayEncrypted(const CServer* const pServer)
456
void CStatusBar::DisplayEncrypted()
403
delete m_pCertificate;
405
delete m_pSftpEncryptionInfo;
406
m_pSftpEncryptionInfo = 0;
458
const CServer* pServer = 0;
459
const CState* pState = CContextManager::Get()->GetCurrentContext();
461
pServer = pState->GetServer();
407
463
if (!pServer || (pServer->GetProtocol() != FTPS && pServer->GetProtocol() != FTPES && pServer->GetProtocol() != SFTP))
409
465
if (m_pEncryptionIndicator)
411
RemoveChild(-4, m_pEncryptionIndicator);
467
RemoveChild(widget_encryption);
412
468
m_pEncryptionIndicator->Destroy();
413
469
m_pEncryptionIndicator = 0;
444
500
void CStatusBar::OnHandleLeftClick(wxWindow* pWnd)
446
if (pWnd != m_pEncryptionIndicator)
451
CVerifyCertDialog dlg;
452
dlg.ShowVerificationDialog(m_pCertificate, true);
454
else if (m_pSftpEncryptionInfo)
456
CSftpEncryptioInfoDialog dlg;
457
dlg.ShowDialog(m_pSftpEncryptionInfo);
460
wxMessageBox(_("Certificate and session data are not available yet."), _("Security information"));
502
if (pWnd == m_pEncryptionIndicator)
504
CState* pState = CContextManager::Get()->GetCurrentContext();
505
CCertificateNotification *pCertificateNotification = 0;
506
CSftpEncryptionNotification *pSftpEncryptionNotification = 0;
507
if (pState->GetSecurityInfo(pCertificateNotification))
509
CVerifyCertDialog dlg;
510
dlg.ShowVerificationDialog(pCertificateNotification, true);
512
else if (pState->GetSecurityInfo(pSftpEncryptionNotification))
514
CSftpEncryptioInfoDialog dlg;
515
dlg.ShowDialog(pSftpEncryptionNotification);
518
wxMessageBox(_("Certificate and session data are not available yet."), _("Security information"));
520
else if (pWnd == m_pSpeedLimitsIndicator)
522
CSpeedLimitsDialog dlg;
463
527
void CStatusBar::OnHandleRightClick(wxWindow* pWnd)
465
if (pWnd != m_pDataTypeIndicator)
468
wxMenu* pMenu = wxXmlResource::Get()->LoadMenu(_T("ID_MENU_TRANSFER_TYPE_CONTEXT"));
472
const int type = COptions::Get()->GetOptionVal(OPTION_ASCIIBINARY);
476
pMenu->Check(XRCID("ID_MENU_TRANSFER_TYPE_ASCII"), true);
479
pMenu->Check(XRCID("ID_MENU_TRANSFER_TYPE_BINARY"), true);
529
if (pWnd == m_pDataTypeIndicator)
531
wxMenu* pMenu = wxXmlResource::Get()->LoadMenu(_T("ID_MENU_TRANSFER_TYPE_CONTEXT"));
535
const int type = COptions::Get()->GetOptionVal(OPTION_ASCIIBINARY);
539
pMenu->Check(XRCID("ID_MENU_TRANSFER_TYPE_ASCII"), true);
542
pMenu->Check(XRCID("ID_MENU_TRANSFER_TYPE_BINARY"), true);
545
pMenu->Check(XRCID("ID_MENU_TRANSFER_TYPE_AUTO"), true);
552
else if (pWnd == m_pSpeedLimitsIndicator)
554
wxMenu* pMenu = wxXmlResource::Get()->LoadMenu(_T("ID_MENU_SPEEDLIMITCONTEXT"));
558
int downloadlimit = COptions::Get()->GetOptionVal(OPTION_SPEEDLIMIT_INBOUND);
559
int uploadlimit = COptions::Get()->GetOptionVal(OPTION_SPEEDLIMIT_OUTBOUND);
560
bool enable = COptions::Get()->GetOptionVal(OPTION_SPEEDLIMIT_ENABLE) != 0;
561
if (!downloadlimit && !uploadlimit)
563
pMenu->Check(XRCID("ID_SPEEDLIMITCONTEXT_ENABLE"), enable);
570
void CStatusBar::UpdateSpeedLimitsIcon()
572
bool enable = COptions::Get()->GetOptionVal(OPTION_SPEEDLIMIT_ENABLE) != 0;
574
wxBitmap bmp = wxArtProvider::GetBitmap(_T("ART_SPEEDLIMITS"), wxART_OTHER, wxSize(16, 16));
577
int downloadLimit = COptions::Get()->GetOptionVal(OPTION_SPEEDLIMIT_INBOUND);
578
int uploadLimit = COptions::Get()->GetOptionVal(OPTION_SPEEDLIMIT_OUTBOUND);
579
if (!enable || (!downloadLimit && !uploadLimit))
581
wxImage img = bmp.ConvertToImage();
582
img = img.ConvertToGreyscale();
584
tooltip = _("Speed limits are disabled, click to change.");
588
tooltip = _("Speed limits are enabled, click to change.");
591
tooltip += wxString::Format(_("Download limit: %s/s"), CSizeFormat::FormatUnit(downloadLimit, CSizeFormat::kilo).c_str());
593
tooltip += _("Download limit: none");
596
tooltip += wxString::Format(_("Upload limit: %s/s"), CSizeFormat::FormatUnit(uploadLimit, CSizeFormat::kilo).c_str());
598
tooltip += _("Upload limit: none");
601
if (!m_pSpeedLimitsIndicator)
603
m_pSpeedLimitsIndicator = new CIndicator(this, bmp);
604
AddChild(0, widget_speedlimit, m_pSpeedLimitsIndicator);
608
m_pSpeedLimitsIndicator->SetBitmap(bmp);
610
m_pSpeedLimitsIndicator->SetToolTip(tooltip);
613
void CStatusBar::OnOptionChanged(int option)
617
case OPTION_SPEEDLIMIT_ENABLE:
618
case OPTION_SPEEDLIMIT_INBOUND:
619
case OPTION_SPEEDLIMIT_OUTBOUND:
620
UpdateSpeedLimitsIcon();
622
case OPTION_SIZE_FORMAT:
623
case OPTION_SIZE_USETHOUSANDSEP:
624
case OPTION_SIZE_DECIMALPLACES:
627
case OPTION_ASCIIBINARY:
482
pMenu->Check(XRCID("ID_MENU_TRANSFER_TYPE_AUTO"), true);
490
void CStatusBar::SetCertificate(CCertificateNotification* pCertificate)
492
delete m_pSftpEncryptionInfo;
493
m_pSftpEncryptionInfo = 0;
495
delete m_pCertificate;
497
m_pCertificate = new CCertificateNotification(*pCertificate);
502
void CStatusBar::SetSftpEncryptionInfo(const CSftpEncryptionNotification* pEncryptionInfo)
504
delete m_pCertificate;
507
delete m_pSftpEncryptionInfo;
509
m_pSftpEncryptionInfo = new CSftpEncryptionNotification(*pEncryptionInfo);
511
m_pSftpEncryptionInfo = 0;
635
void CStatusBar::OnStateChange(CState* pState, enum t_statechange_notifications notification, const wxString& data, const void* data2)
637
if (notification == STATECHANGE_SERVER || notification == STATECHANGE_CHANGEDCONTEXT)
644
void CStatusBar::OnSpeedLimitsEnable(wxCommandEvent& event)
646
int downloadlimit = COptions::Get()->GetOptionVal(OPTION_SPEEDLIMIT_INBOUND);
647
int uploadlimit = COptions::Get()->GetOptionVal(OPTION_SPEEDLIMIT_OUTBOUND);
648
bool enable = COptions::Get()->GetOptionVal(OPTION_SPEEDLIMIT_ENABLE) == 0;
651
if (!downloadlimit && !uploadlimit)
653
CSpeedLimitsDialog dlg;
657
COptions::Get()->SetOption(OPTION_SPEEDLIMIT_ENABLE, 1);
660
COptions::Get()->SetOption(OPTION_SPEEDLIMIT_ENABLE, 0);
663
void CStatusBar::OnSpeedLimitsConfigure(wxCommandEvent& event)
665
CSpeedLimitsDialog dlg;