Skip to content

Commit

Permalink
Fix path of wxdirpickerctrl.png: (#3484)
Browse files Browse the repository at this point in the history
../../wxcrafter/resources/wxdirpickerctrl.png -> ../wxcrafter/resources/wxdirpickerctrl.png
and re-run wxCrafter on LiteEditor/reconcileproject.wxcp
  • Loading branch information
Jarod42 authored Oct 8, 2024
1 parent 39c244b commit bf3c78c
Show file tree
Hide file tree
Showing 6 changed files with 735 additions and 584 deletions.
163 changes: 69 additions & 94 deletions LiteEditor/assignedfilesmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,46 @@
// Do not modify this file by hand!
//////////////////////////////////////////////////////////////////////

#ifndef __AssignedFilesModel_GUARD__H__
#define __AssignedFilesModel_GUARD__H__
#ifndef __ASSIGNEDFILESMODEL_GUARD__H__
#define __ASSIGNEDFILESMODEL_GUARD__H__

#include <wx/variant.h>
#include <wx/dataview.h>
#include <algorithm>
#include <wx/clntdata.h>
#include <wx/dataview.h>
#include <wx/variant.h>

/**
* @brief each item in the wxDataViewCtrl is represented in the model by this class.
* m_data - contains the data (columns values) as passed when adding an item to the wxDataViewCtrl model class
* m_clientData - is the user client data (owned by the model)
* m_data - contains the data (columns values) as passed when adding an item to the wxDataViewCtrl model class
* m_clientData - is the user client data (owned by the model)
* To convert between a wxDataViewItem to a AssignedFilesModel_Item class, simply use:
* @code
* AssignedFilesModel_Item* itemData = reinterpret_cast<AssignedFilesModel_Item*>( item.GetID() );
* if ( itemData ) {
* // you can now traverese the tree or have a direct access to the model internal data
* // note that you must not delete itemData as it is owned by the model and
* // you can now traverse the tree or have a direct access to the model internal data
* // note that you must not delete itemData as it is owned by the model
* }
* @endcode
*/
class AssignedFilesModel_Item
{
protected:
wxVector<wxVariant> m_data;
AssignedFilesModel_Item* m_parent;
wxVector<wxVariant> m_data;
AssignedFilesModel_Item* m_parent;
wxVector<AssignedFilesModel_Item*> m_children;
bool m_isContainer;
wxClientData* m_clientData;
bool m_isContainer;
wxClientData* m_clientData;

public:
AssignedFilesModel_Item()
: m_parent(NULL)
, m_isContainer(false)
, m_clientData(NULL)
{}
virtual ~AssignedFilesModel_Item() {
if ( m_clientData ) {
{
}
virtual ~AssignedFilesModel_Item()
{
if (m_clientData) {
delete m_clientData;
m_clientData = NULL;
}
Expand All @@ -50,33 +52,30 @@ class AssignedFilesModel_Item
// since the deletion of a child may alter its parent m_children array
// we use a temporary vector for the loop
wxVector<AssignedFilesModel_Item*> tmpChildren = m_children;
while ( !tmpChildren.empty() ) {
while (!tmpChildren.empty()) {
delete (*tmpChildren.begin());
tmpChildren.erase(tmpChildren.begin());
}
m_children.clear();

// Remove us from the parent
if ( m_parent ) {
if (m_parent) {
m_parent->RemoveChild(this);
}
}

void SetIsContainer(bool b) {
m_isContainer = b;
}
void SetIsContainer(bool b) { m_isContainer = b; }

bool IsContainer() const {
return m_isContainer;
}
bool IsContainer() const { return m_isContainer; }

/**
* @brief remove a child from this node and free its memory
* @param child
*/
void DeleteChild(AssignedFilesModel_Item* child) {
void DeleteChild(AssignedFilesModel_Item* child)
{
wxVector<AssignedFilesModel_Item*>::iterator iter = std::find(m_children.begin(), m_children.end(), child);
if ( iter != m_children.end() ) {
if (iter != m_children.end()) {
delete *iter;
m_children.erase(iter);
}
Expand All @@ -86,61 +85,44 @@ class AssignedFilesModel_Item
* @brief remove child from this node without freeing its memory
* @param child
*/
void RemoveChild(AssignedFilesModel_Item* child) {
void RemoveChild(AssignedFilesModel_Item* child)
{
wxVector<AssignedFilesModel_Item*>::iterator iter = std::find(m_children.begin(), m_children.end(), child);
if ( iter != m_children.end() ) {
if (iter != m_children.end()) {
m_children.erase(iter);
}
}

/**
* @brief add child to this node
*/
void AddChild(AssignedFilesModel_Item* child) {
void AddChild(AssignedFilesModel_Item* child)
{
m_children.push_back(child);
child->m_parent = this;
}

bool IsRoot() const {
return m_parent == NULL;
}
bool IsRoot() const { return m_parent == NULL; }

// Setters / Getters
void SetChildren(const wxVector<AssignedFilesModel_Item*>& children) {
this->m_children = children;
}
void SetData(const wxVector<wxVariant>& data) {
this->m_data = data;
}
void SetParent(AssignedFilesModel_Item* parent) {
this->m_parent = parent;
}
const wxVector<AssignedFilesModel_Item*>& GetChildren() const {
return m_children;
}
wxVector<AssignedFilesModel_Item*>& GetChildren() {
return m_children;
}
const wxVector<wxVariant>& GetData() const {
return m_data;
}
wxVector<wxVariant>& GetData() {
return m_data;
}
AssignedFilesModel_Item* GetParent() {
return m_parent;
}

void SetClientObject(wxClientData *data) {
if ( m_clientData ) {
void SetChildren(const wxVector<AssignedFilesModel_Item*>& children) { this->m_children = children; }
void SetData(const wxVector<wxVariant>& data) { this->m_data = data; }
void SetParent(AssignedFilesModel_Item* parent) { this->m_parent = parent; }
const wxVector<AssignedFilesModel_Item*>& GetChildren() const { return m_children; }
wxVector<AssignedFilesModel_Item*>& GetChildren() { return m_children; }
const wxVector<wxVariant>& GetData() const { return m_data; }
wxVector<wxVariant>& GetData() { return m_data; }
AssignedFilesModel_Item* GetParent() { return m_parent; }

void SetClientObject(wxClientData* data)
{
if (m_clientData) {
delete m_clientData;
}
m_clientData = data;
}

wxClientData* GetClientObject() const {
return m_clientData;
}
wxClientData* GetClientObject() const { return m_clientData; }
};

//////////////////////////////////////////////
Expand All @@ -156,57 +138,49 @@ class AssignedFilesModel : public wxDataViewModel
public:
AssignedFilesModel();
virtual ~AssignedFilesModel();

/**
* @brief a helper method creating a wxVariant containing both bitmap and text
* this is useful when mostly when populating a column of type 'icontext'
*/
static wxVariant CreateIconTextVariant(const wxString &text, const wxBitmap& bmp);

void SetColCount(unsigned int colCount) {
this->m_colCount = colCount;
}
void SetData(const wxVector<AssignedFilesModel_Item*> data) {
this->m_data = data;
}
unsigned int GetColCount() const {
return m_colCount;
}
const wxVector<AssignedFilesModel_Item*>& GetData() const {
return m_data;
}
wxVector<AssignedFilesModel_Item*>& GetData() {
return m_data;
}
static wxVariant CreateIconTextVariant(const wxString& text, const wxBitmap& bmp);

virtual bool HasContainerColumns (const wxDataViewItem& item) const {
return true;
}
void SetColCount(unsigned int colCount) { this->m_colCount = colCount; }
void SetData(const wxVector<AssignedFilesModel_Item*> data) { this->m_data = data; }
unsigned int GetColCount() const { return m_colCount; }
const wxVector<AssignedFilesModel_Item*>& GetData() const { return m_data; }
wxVector<AssignedFilesModel_Item*>& GetData() { return m_data; }

virtual bool HasContainerColumns(const wxDataViewItem& item) const { return true; }

public:
// Make the functions below 'virtual' so the user may override them
virtual unsigned int GetColumnCount() const;
virtual wxString GetColumnType(unsigned int col) const;
virtual void GetValue(wxVariant& variant, const wxDataViewItem& item, unsigned int col) const;
virtual bool SetValue(const wxVariant &variant, const wxDataViewItem &item, unsigned int col);
virtual bool SetValue(const wxVariant& variant, const wxDataViewItem& item, unsigned int col);

protected:
// Helpers
virtual wxDataViewItem DoAppendItem(const wxDataViewItem& parent, const wxVector<wxVariant>& data, bool isContainer, wxClientData *clientData = NULL);
virtual wxDataViewItem DoInsertItem(const wxDataViewItem& insertBeforeMe, const wxVector<wxVariant>& data, bool isContainer, wxClientData *clientData);
virtual wxDataViewItem DoAppendItem(const wxDataViewItem& parent, const wxVector<wxVariant>& data, bool isContainer,
wxClientData* clientData = NULL);
virtual wxDataViewItem DoInsertItem(const wxDataViewItem& insertBeforeMe, const wxVector<wxVariant>& data,
bool isContainer, wxClientData* clientData);
virtual void DoChangeItemType(const wxDataViewItem& item, bool changeToContainer);

public:
/**
* @brief Append a line to the model
* clientData will be owned by the model once added (i.e. the clientData must be allocated on the heap and it will be freed by the model)
* clientData will be owned by the model once added (i.e. the clientData must be allocated on the heap and it will
* be freed by the model)
*/
virtual wxDataViewItem AppendItem(const wxDataViewItem& parent, const wxVector<wxVariant>& data, wxClientData *clientData = NULL);
virtual wxDataViewItem AppendItem(const wxDataViewItem& parent, const wxVector<wxVariant>& data,
wxClientData* clientData = NULL);

/**
* @brief Append a lines to the model
*/
virtual wxDataViewItemArray AppendItems(const wxDataViewItem& parent, const wxVector<wxVector<wxVariant> >& data);
virtual wxDataViewItemArray AppendItems(const wxDataViewItem& parent, const wxVector<wxVector<wxVariant>>& data);

/**
* @brief delete an item and all its children
Expand All @@ -228,7 +202,8 @@ class AssignedFilesModel : public wxDataViewModel
/**
* @brief insert an item into the model before 'insertBeforeMe' item. Return the newly inserted item on success
*/
virtual wxDataViewItem InsertItem (const wxDataViewItem& insertBeforeMe, const wxVector<wxVariant>& data, wxClientData *clientData = NULL);
virtual wxDataViewItem InsertItem(const wxDataViewItem& insertBeforeMe, const wxVector<wxVariant>& data,
wxClientData* clientData = NULL);

/**
* @brief clear the control and delete all its content
Expand All @@ -245,16 +220,16 @@ class AssignedFilesModel : public wxDataViewModel
/**
* @brief set the client data for an item. The item data will be freed by the model
*/
void SetClientObject(const wxDataViewItem& item, wxClientData *data);
void SetClientObject(const wxDataViewItem& item, wxClientData* data);

/**
* @brief returns the item columns data (as passed to AppendItem(..) / InsertItem(...))
*/
wxVector<wxVariant> GetItemColumnsData(const wxDataViewItem& item) const;

/**
* @brief return true if this node is a container (i.e. has children)
*/
* @brief return true if this node is a container (i.e. has children)
*/
virtual bool IsContainer(const wxDataViewItem& item) const;

/**
Expand All @@ -273,4 +248,4 @@ class AssignedFilesModel : public wxDataViewModel
*/
virtual unsigned int GetChildren(const wxDataViewItem& item, wxDataViewItemArray& children) const;
};
#endif // __AssignedFilesModel_GUARD__H__
#endif // __ASSIGNEDFILESMODEL_GUARD__H__
Loading

0 comments on commit bf3c78c

Please sign in to comment.