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
|
#include "PHPSettersGettersDialog.h"
#include "windowattrmanager.h"
#include "php_code_completion.h"
#include "php_configuration_data.h"
#include "bitmap_loader.h"
#include "imanager.h"
#include "ieditor.h"
#include "globals.h"
struct PHPSettersGettersDialogClientData {
PHPEntityBase::Ptr_t m_member;
PHPSettersGettersDialogClientData(PHPEntityBase::Ptr_t member)
: m_member(member)
{
}
~PHPSettersGettersDialogClientData() {}
};
PHPSettersGettersDialog::PHPSettersGettersDialog(wxWindow* parent, IEditor* editor, IManager* mgr)
: PHPSettersGettersDialogBase(parent)
, m_editor(editor)
, m_mgr(mgr)
{
PHPConfigurationData conf;
size_t flags = conf.Load().GetSettersGettersFlags();
m_checkBoxLowercase->SetValue(flags & kSG_StartWithLowercase);
m_checkBoxPrefixGetter->SetValue(!(flags & kSG_NoPrefix));
m_checkBoxReurnThis->SetValue(flags & kSG_ReturnThis);
CenterOnParent();
SetName("PHPSettersGettersDialog");
WindowAttrManager::Load(this);
PHPEntityBase::List_t members;
PHPCodeCompletion::Instance()->GetMembers(editor, members, m_scope);
DoPopulate(members);
}
PHPSettersGettersDialog::~PHPSettersGettersDialog()
{
PHPConfigurationData conf;
conf.Load().SetSettersGettersFlags(GetFlags()).Save();
Clear();
}
void PHPSettersGettersDialog::DoPopulate(const PHPEntityBase::List_t& members)
{
Clear();
BitmapLoader* bmpLoader = m_mgr->GetStdIcons();
wxBitmap memberBmp = bmpLoader->LoadBitmap("cc/16/member_public");
m_dvListCtrlFunctions->DeleteAllItems();
PHPEntityBase::List_t::const_iterator iter = members.begin();
for(; iter != members.end(); ++iter) {
wxVector<wxVariant> cols;
cols.push_back(false);
cols.push_back(::MakeIconText((*iter)->GetDisplayName(), memberBmp));
m_dvListCtrlFunctions->AppendItem(cols, (wxUIntPtr) new PHPSettersGettersDialogClientData(*iter));
}
}
void PHPSettersGettersDialog::Clear()
{
for(int i = 0; i < m_dvListCtrlFunctions->GetItemCount(); ++i) {
PHPSettersGettersDialogClientData* cd = reinterpret_cast<PHPSettersGettersDialogClientData*>(
m_dvListCtrlFunctions->GetItemData(m_dvListCtrlFunctions->RowToItem(i)));
wxDELETE(cd);
}
m_dvListCtrlFunctions->DeleteAllItems();
}
PHPSetterGetterEntry::Vec_t PHPSettersGettersDialog::GetMembers()
{
PHPSetterGetterEntry::Vec_t members;
for(int i = 0; i < m_dvListCtrlFunctions->GetItemCount(); ++i) {
PHPSettersGettersDialogClientData* cd = reinterpret_cast<PHPSettersGettersDialogClientData*>(
m_dvListCtrlFunctions->GetItemData(m_dvListCtrlFunctions->RowToItem(i)));
wxVariant val;
m_dvListCtrlFunctions->GetValue(val, i, 0);
if(val.GetBool()) {
// This item is checked
PHPSetterGetterEntry entry(cd->m_member);
members.push_back(entry);
}
}
return members;
}
size_t PHPSettersGettersDialog::GetFlags()
{
size_t flags = 0;
if(m_checkBoxLowercase->IsChecked()) flags |= kSG_StartWithLowercase;
if(!m_checkBoxPrefixGetter->IsChecked()) flags |= kSG_NoPrefix;
if(m_checkBoxReurnThis->IsChecked()) flags |= kSG_ReturnThis;
return flags;
}
|