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
|
#include "DefaultWorkspacePage.h"
#include "clFileOrFolderDropTarget.h"
#include "codelite_events.h"
#include "globals.h"
#include <imanager.h>
#include "clWorkspaceView.h"
#include <wx/simplebook.h>
#include "event_notifier.h"
#include <algorithm>
#include "SelectDropTargetDlg.h"
#include "cl_config.h"
#include "clSystemSettings.h"
#include <wx/dcbuffer.h>
DefaultWorkspacePage::DefaultWorkspacePage(wxWindow* parent)
: DefaultWorkspacePageBase(parent)
{
// Allow the PHP view to accepts folders
SetBackgroundStyle(wxBG_STYLE_PAINT);
wxColour bg = clSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
m_colours.InitFromColour(bg);
if(clConfig::Get().Read("UseCustomBaseColour", false)) {
bg = clConfig::Get().Read("BaseColour", bg);
m_colours.InitFromColour(bg);
}
m_staticText523->SetBackgroundColour(m_colours.GetBgColour());
m_staticText523->SetForegroundColour(m_colours.GetItemTextColour());
SetDropTarget(new clFileOrFolderDropTarget(this));
m_staticText523->SetBackgroundColour(m_colours.GetBgColour());
m_staticText523->SetForegroundColour(m_colours.GetItemTextColour());
SetBackgroundColour(clSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
m_staticBitmap521->SetDropTarget(new clFileOrFolderDropTarget(this));
Bind(wxEVT_DND_FOLDER_DROPPED, &DefaultWorkspacePage::OnFolderDropped, this);
EventNotifier::Get()->Bind(wxEVT_CMD_COLOURS_FONTS_UPDATED, &DefaultWorkspacePage::OnColoursChanged, this);
Bind(wxEVT_PAINT, &DefaultWorkspacePage::OnPaint, this);
Bind(wxEVT_ERASE_BACKGROUND, [](wxEraseEvent& e) { wxUnusedVar(e); });
}
DefaultWorkspacePage::~DefaultWorkspacePage()
{
Unbind(wxEVT_PAINT, &DefaultWorkspacePage::OnPaint, this);
Unbind(wxEVT_DND_FOLDER_DROPPED, &DefaultWorkspacePage::OnFolderDropped, this);
EventNotifier::Get()->Unbind(wxEVT_CMD_COLOURS_FONTS_UPDATED, &DefaultWorkspacePage::OnColoursChanged, this);
}
void DefaultWorkspacePage::OnFolderDropped(clCommandEvent& event)
{
const wxArrayString& folders = event.GetStrings();
CallAfter(&DefaultWorkspacePage::DoDropFolders, folders);
}
void DefaultWorkspacePage::DoDropFolders(const wxArrayString& folders)
{
SelectDropTargetDlg dropTargetDlg(EventNotifier::Get()->TopFrame(), folders);
dropTargetDlg.ShowModal();
}
void DefaultWorkspacePage::OnColoursChanged(clCommandEvent& event)
{
event.Skip();
wxColour bg = clSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
m_colours.InitFromColour(bg);
bool useCustom = clConfig::Get().Read("UseCustomBaseColour", false);
if(useCustom) {
bg = clConfig::Get().Read("BaseColour", bg);
m_colours.InitFromColour(bg);
}
m_staticText523->SetBackgroundColour(m_colours.GetBgColour());
m_staticText523->SetForegroundColour(m_colours.GetItemTextColour());
}
void DefaultWorkspacePage::OnPaint(wxPaintEvent& event)
{
wxAutoBufferedPaintDC dc(this);
dc.SetBrush(m_colours.GetBgColour());
dc.SetPen(m_colours.GetBgColour());
dc.DrawRectangle(GetClientRect());
}
|