| 1 |
#include "wxgui_globals.h" |
| 2 |
#include <wx/busyinfo.h> |
| 3 |
#include <wx/log.h> |
| 4 |
#include <wx/wfstream.h> |
| 5 |
#include <wx/zipstrm.h> |
| 6 |
|
| 7 |
namespace wxCrafter |
| 8 |
{ |
| 9 |
void SetColumnText(wxListCtrl* list, long indx, long column, const wxString& rText, int imgId) |
| 10 |
{ |
| 11 |
wxListItem list_item; |
| 12 |
list_item.SetId(indx); |
| 13 |
list_item.SetColumn(column); |
| 14 |
list_item.SetMask(wxLIST_MASK_TEXT); |
| 15 |
list_item.SetText(rText); |
| 16 |
list_item.SetImage(imgId); |
| 17 |
list->SetItem(list_item); |
| 18 |
} |
| 19 |
|
| 20 |
wxString GetColumnText(wxListCtrl* list, long index, long column) |
| 21 |
{ |
| 22 |
wxListItem list_item; |
| 23 |
list_item.SetId(index); |
| 24 |
list_item.SetColumn(column); |
| 25 |
list_item.SetMask(wxLIST_MASK_TEXT); |
| 26 |
list->GetItem(list_item); |
| 27 |
return list_item.GetText(); |
| 28 |
} |
| 29 |
|
| 30 |
long AppendListCtrlRow(wxListCtrl* list) |
| 31 |
{ |
| 32 |
long item; |
| 33 |
list->GetItemCount() ? item = list->GetItemCount() : item = 0; |
| 34 |
|
| 35 |
wxListItem info; |
| 36 |
// Set the item display name |
| 37 |
info.SetColumn(0); |
| 38 |
info.SetId(item); |
| 39 |
item = list->InsertItem(info); |
| 40 |
return item; |
| 41 |
} |
| 42 |
|
| 43 |
bool ReadFileContent(const wxString& fileName, wxString& content) |
| 44 |
{ |
| 45 |
wxLogNull noLog; |
| 46 |
content.Clear(); |
| 47 |
wxFFile file(fileName, wxT("rb")); |
| 48 |
|
| 49 |
if(file.IsOpened()) { |
| 50 |
|
| 51 |
file.ReadAll(&content); |
| 52 |
if(content.IsEmpty()) { |
| 53 |
// now try the Utf8 |
| 54 |
file.ReadAll(&content, wxConvUTF8); |
| 55 |
} |
| 56 |
} |
| 57 |
return !content.IsEmpty(); |
| 58 |
} |
| 59 |
|
| 60 |
} // namespace wxCrafter |