1. wxShell fixes: now really uses shell (it wasn't different from wxExecute!)
and also added a version which captures the programs output 2. fix for compilers which have void ftime() (my mingw does) in timercmn.cpp 3. updated console sample to test wxShell/wxExecute 4. treetest now can toggle images or change their size 5. wxTreeCtrl doesn't crash if it has no image list git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6404 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
914589c26c
commit
2c8e47380e
@ -176,10 +176,14 @@ enum wxSignal
|
||||
// the argument is ignored under Windows - the process is always killed
|
||||
WXDLLEXPORT int wxKill(long pid, wxSignal sig = wxSIGTERM);
|
||||
|
||||
// Execute a command in an interactive shell window
|
||||
// Execute a command in an interactive shell window (always synchronously)
|
||||
// If no command then just the shell
|
||||
WXDLLEXPORT bool wxShell(const wxString& command = wxEmptyString);
|
||||
|
||||
// As wxShell(), but must give a (non interactive) command and its output will
|
||||
// be returned in output array
|
||||
WXDLLEXPORT bool wxShell(const wxString& command, wxArrayString& output);
|
||||
|
||||
// Sleep for nSecs seconds
|
||||
WXDLLEXPORT void wxSleep(int nSecs);
|
||||
|
||||
|
@ -32,11 +32,13 @@
|
||||
//#define TEST_ARRAYS
|
||||
//#define TEST_CMDLINE
|
||||
//#define TEST_DIR
|
||||
//#define TEST_EXECUTE
|
||||
#define TEST_FILECONF
|
||||
#define TEST_EXECUTE
|
||||
//#define TEST_FILECONF
|
||||
//#define TEST_HASH
|
||||
//#define TEST_LOG
|
||||
//#define TEST_LONGLONG
|
||||
//#define TEST_MIME
|
||||
//#define TEST_SOCKETS
|
||||
//#define TEST_STRINGS
|
||||
//#define TEST_THREADS
|
||||
//#define TEST_TIME
|
||||
@ -176,16 +178,55 @@ static void TestExecute()
|
||||
|
||||
#ifdef __UNIX__
|
||||
#define COMMAND "echo hi"
|
||||
#define SHELL_COMMAND "echo hi from shell"
|
||||
#define REDIRECT_COMMAND "date"
|
||||
#elif defined(__WXMSW__)
|
||||
#define COMMAND "command.com -c 'echo hi'"
|
||||
#define SHELL_COMMAND "echo hi"
|
||||
#define REDIRECT_COMMAND COMMAND
|
||||
#else
|
||||
#error "no command to exec"
|
||||
#endif // OS
|
||||
|
||||
if ( wxExecute(COMMAND) == 0 )
|
||||
puts("\nOk.");
|
||||
printf("Testing wxShell: ");
|
||||
fflush(stdout);
|
||||
if ( wxShell(SHELL_COMMAND) )
|
||||
puts("Ok.");
|
||||
else
|
||||
puts("\nError.");
|
||||
puts("ERROR.");
|
||||
|
||||
printf("Testing wxExecute: ");
|
||||
fflush(stdout);
|
||||
if ( wxExecute(COMMAND, TRUE /* sync */) == 0 )
|
||||
puts("Ok.");
|
||||
else
|
||||
puts("ERROR.");
|
||||
|
||||
#if 0 // no, it doesn't work (yet?)
|
||||
printf("Testing async wxExecute: ");
|
||||
fflush(stdout);
|
||||
if ( wxExecute(COMMAND) != 0 )
|
||||
puts("Ok (command launched).");
|
||||
else
|
||||
puts("ERROR.");
|
||||
#endif // 0
|
||||
|
||||
printf("Testing wxExecute with redirection:\n");
|
||||
wxArrayString output;
|
||||
if ( wxExecute(REDIRECT_COMMAND, output) != 0 )
|
||||
{
|
||||
puts("ERROR.");
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t count = output.GetCount();
|
||||
for ( size_t n = 0; n < count; n++ )
|
||||
{
|
||||
printf("\t%s\n", output[n].c_str());
|
||||
}
|
||||
|
||||
puts("Ok.");
|
||||
}
|
||||
}
|
||||
|
||||
#endif // TEST_EXECUTE
|
||||
@ -253,6 +294,92 @@ static void TestFileConfRead()
|
||||
|
||||
#endif // TEST_FILECONF
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxHashTable
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef TEST_HASH
|
||||
|
||||
#include <wx/hash.h>
|
||||
|
||||
struct Foo
|
||||
{
|
||||
Foo(int n_) { n = n_; count++; }
|
||||
~Foo() { count--; }
|
||||
|
||||
int n;
|
||||
|
||||
static size_t count;
|
||||
};
|
||||
|
||||
size_t Foo::count = 0;
|
||||
|
||||
WX_DECLARE_LIST(Foo, wxListFoos);
|
||||
WX_DECLARE_HASH(Foo, wxListFoos, wxHashFoos);
|
||||
|
||||
#include <wx/listimpl.cpp>
|
||||
|
||||
WX_DEFINE_LIST(wxListFoos);
|
||||
|
||||
static void TestHash()
|
||||
{
|
||||
puts("*** Testing wxHashTable ***\n");
|
||||
|
||||
{
|
||||
wxHashFoos hash;
|
||||
hash.DeleteContents(TRUE);
|
||||
|
||||
printf("Hash created: %u foos in hash, %u foos totally\n",
|
||||
hash.GetCount(), Foo::count);
|
||||
|
||||
static const int hashTestData[] =
|
||||
{
|
||||
0, 1, 17, -2, 2, 4, -4, 345, 3, 3, 2, 1,
|
||||
};
|
||||
|
||||
size_t n;
|
||||
for ( n = 0; n < WXSIZEOF(hashTestData); n++ )
|
||||
{
|
||||
hash.Put(hashTestData[n], n, new Foo(n));
|
||||
}
|
||||
|
||||
printf("Hash filled: %u foos in hash, %u foos totally\n",
|
||||
hash.GetCount(), Foo::count);
|
||||
|
||||
puts("Hash access test:");
|
||||
for ( n = 0; n < WXSIZEOF(hashTestData); n++ )
|
||||
{
|
||||
printf("\tGetting element with key %d, value %d: ",
|
||||
hashTestData[n], n);
|
||||
Foo *foo = hash.Get(hashTestData[n], n);
|
||||
if ( !foo )
|
||||
{
|
||||
printf("ERROR, not found.\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("%d (%s)\n", foo->n,
|
||||
(size_t)foo->n == n ? "ok" : "ERROR");
|
||||
}
|
||||
}
|
||||
|
||||
printf("\nTrying to get an element not in hash: ");
|
||||
|
||||
if ( hash.Get(1234) || hash.Get(1, 0) )
|
||||
{
|
||||
puts("ERROR: found!");
|
||||
}
|
||||
else
|
||||
{
|
||||
puts("ok (not found)");
|
||||
}
|
||||
}
|
||||
|
||||
printf("Hash destroyed: %u foos left\n", Foo::count);
|
||||
}
|
||||
|
||||
#endif // TEST_HASH
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// MIME types
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -555,6 +682,39 @@ static void TestBitOperations()
|
||||
|
||||
#endif // TEST_LONGLONG
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// sockets
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef TEST_SOCKETS
|
||||
|
||||
#include <wx/socket.h>
|
||||
|
||||
static void TestSocketClient()
|
||||
{
|
||||
puts("*** Testing wxSocketClient ***\n");
|
||||
|
||||
wxIPV4address addrDst;
|
||||
addrDst.Hostname("www.wxwindows.org");
|
||||
addrDst.Service(80);
|
||||
|
||||
wxSocketClient client;
|
||||
if ( !client.Connect(addrDst) )
|
||||
{
|
||||
printf("ERROR: failed to connect to %s\n", addrDst.Hostname().c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
char buf[8192];
|
||||
|
||||
client.Write("get /front.htm\n", 17);
|
||||
client.Read(buf, WXSIZEOF(buf));
|
||||
printf("Server replied:\n%s", buf);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // TEST_SOCKETS
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// date time
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -2217,10 +2377,18 @@ int main(int argc, char **argv)
|
||||
}
|
||||
#endif // TEST_LONGLONG
|
||||
|
||||
#ifdef TEST_HASH
|
||||
TestHash();
|
||||
#endif // TEST_HASH
|
||||
|
||||
#ifdef TEST_MIME
|
||||
TestMimeEnum();
|
||||
#endif // TEST_MIME
|
||||
|
||||
#ifdef TEST_SOCKETS
|
||||
TestSocketClient();
|
||||
#endif // TEST_SOCKETS
|
||||
|
||||
#ifdef TEST_TIME
|
||||
if ( 0 )
|
||||
{
|
||||
|
@ -1148,6 +1148,7 @@ void MyPanel::OnShowProgress( wxCommandEvent& WXUNUSED(event) )
|
||||
max, // range
|
||||
this, // parent
|
||||
wxPD_CAN_ABORT |
|
||||
wxPD_AUTO_HIDE |
|
||||
wxPD_APP_MODAL |
|
||||
wxPD_ELAPSED_TIME |
|
||||
wxPD_ESTIMATED_TIME |
|
||||
|
@ -242,9 +242,15 @@ void MyFrame::ChooseFontGeneric(wxCommandEvent& WXUNUSED(event) )
|
||||
|
||||
void MyFrame::LogDialog(wxCommandEvent& event)
|
||||
{
|
||||
wxLogMessage("This is some message - everything is ok so far.");
|
||||
wxLogMessage("Another message...\n... this one is on multiple lines");
|
||||
wxLogWarning("And then something went wrong!");
|
||||
// calling wxYield() (as ~wxBusyCursor does) shouldn't result in messages
|
||||
// being flushed -- test it
|
||||
{
|
||||
wxBusyCursor bc;
|
||||
wxLogMessage("This is some message - everything is ok so far.");
|
||||
wxLogMessage("Another message...\n... this one is on multiple lines");
|
||||
wxLogWarning("And then something went wrong!");
|
||||
}
|
||||
|
||||
wxLogError("Intermediary error handler decided to abort.");
|
||||
wxLogError("The top level caller detected an unrecoverable error.");
|
||||
|
||||
|
@ -572,7 +572,9 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
|
||||
m_horizontal = new MyTextCtrl( this, -1, "Multiline text control with a horizontal scrollbar.",
|
||||
wxPoint(10,170), wxSize(140,70), wxTE_MULTILINE | wxHSCROLL );
|
||||
m_horizontal->SetFont(wxFont(18, wxSWISS, wxNORMAL, wxNORMAL,
|
||||
FALSE, "", wxFONTENCODING_KOI8));
|
||||
FALSE, "", wxFONTENCODING_ISO8859_2)); //wxFONTENCODING_KOI8));
|
||||
//m_horizontal->SetValue("ËÁÖÅÔÓÑ ÕÄÁÞÎÙÍ");
|
||||
m_horizontal->SetValue("®lu»ouèký kùò zbìsile èe¹tina «»");
|
||||
|
||||
m_multitext = new MyTextCtrl( this, -1, "Multi line.",
|
||||
wxPoint(180,10), wxSize(240,70), wxTE_MULTILINE );
|
||||
|
@ -33,27 +33,21 @@
|
||||
|
||||
#include "math.h"
|
||||
|
||||
#ifdef __WXMSW__
|
||||
// this is not supported at all under MSW
|
||||
#ifdef __WIN32__
|
||||
// this is not supported by native control
|
||||
#define NO_VARIABLE_HEIGHT
|
||||
|
||||
#define NO_MULTIPLE_SELECTION
|
||||
|
||||
// this is supported (so the next line may be uncommented) but not very
|
||||
// well :-(
|
||||
#undef NO_MULTIPLE_SELECTION
|
||||
#endif
|
||||
|
||||
#include "treetest.h"
|
||||
|
||||
// under Windows the icons are in the .rc file
|
||||
#ifndef __WXMSW__
|
||||
#include "icon1.xpm"
|
||||
#include "icon2.xpm"
|
||||
#include "icon3.xpm"
|
||||
#include "icon4.xpm"
|
||||
#include "icon5.xpm"
|
||||
#include "mondrian.xpm"
|
||||
#include "icon1.xpm"
|
||||
#include "icon2.xpm"
|
||||
#include "icon3.xpm"
|
||||
#include "icon4.xpm"
|
||||
#include "icon5.xpm"
|
||||
#include "mondrian.xpm"
|
||||
#endif
|
||||
|
||||
// verify that the item is ok and insult the user if it is not
|
||||
@ -88,6 +82,8 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
||||
EVT_MENU(TreeTest_DeleteChildren, MyFrame::OnDeleteChildren)
|
||||
EVT_MENU(TreeTest_DeleteAll, MyFrame::OnDeleteAll)
|
||||
EVT_MENU(TreeTest_Recreate, MyFrame::OnRecreate)
|
||||
EVT_MENU(TreeTest_ToggleImages, MyFrame::OnToggleImages)
|
||||
EVT_MENU(TreeTest_SetImageSize, MyFrame::OnSetImageSize)
|
||||
EVT_MENU(TreeTest_CollapseAndReset, MyFrame::OnCollapseAndReset)
|
||||
EVT_MENU(TreeTest_EnsureVisible, MyFrame::OnEnsureVisible)
|
||||
EVT_MENU(TreeTest_AddItem, MyFrame::OnAddItem)
|
||||
@ -161,6 +157,8 @@ MyFrame::MyFrame(const wxString& title, int x, int y, int w, int h)
|
||||
#ifndef NO_MULTIPLE_SELECTION
|
||||
tree_menu->Append(TreeTest_ToggleSel, "&Toggle selection mode");
|
||||
#endif // NO_MULTIPLE_SELECTION
|
||||
tree_menu->Append(TreeTest_ToggleImages, "&Show images", "", TRUE);
|
||||
tree_menu->Append(TreeTest_SetImageSize, "Set image si&ze...");
|
||||
tree_menu->Append(TreeTest_Recreate, "&Recreate the tree");
|
||||
tree_menu->Append(TreeTest_CollapseAndReset, "C&ollapse and reset");
|
||||
tree_menu->AppendSeparator();
|
||||
@ -206,6 +204,8 @@ MyFrame::MyFrame(const wxString& title, int x, int y, int w, int h)
|
||||
menu_bar->Append(item_menu, "&Item");
|
||||
SetMenuBar(menu_bar);
|
||||
|
||||
menu_bar->Check(TreeTest_ToggleImages, TRUE);
|
||||
|
||||
m_treeCtrl = new MyTreeCtrl(this, TreeTest_Ctrl,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxTR_HAS_BUTTONS |
|
||||
@ -412,6 +412,27 @@ void MyFrame::OnRecreate(wxCommandEvent& event)
|
||||
m_treeCtrl->AddTestItemsToTree(3, 2);
|
||||
}
|
||||
|
||||
void MyFrame::OnSetImageSize(wxCommandEvent& event)
|
||||
{
|
||||
long size = wxGetNumberFromUser("Enter the size for the images to use",
|
||||
"Size: ",
|
||||
"TreeCtrl sample",
|
||||
32);
|
||||
if ( size == -1 )
|
||||
return;
|
||||
|
||||
m_treeCtrl->CreateImageList((int)size);
|
||||
|
||||
OnRecreate(event);
|
||||
}
|
||||
|
||||
void MyFrame::OnToggleImages(wxCommandEvent& event)
|
||||
{
|
||||
wxGetApp().SetShowImages(!wxGetApp().ShowImages());
|
||||
|
||||
OnRecreate(event);
|
||||
}
|
||||
|
||||
void MyFrame::OnCollapseAndReset(wxCommandEvent& event)
|
||||
{
|
||||
m_treeCtrl->CollapseAndReset(m_treeCtrl->GetRootItem());
|
||||
@ -424,7 +445,8 @@ void MyFrame::OnEnsureVisible(wxCommandEvent& event)
|
||||
|
||||
void MyFrame::OnInsertItem(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
m_treeCtrl->InsertItem(m_treeCtrl->GetRootItem(), 1, "2nd item");
|
||||
int image = wxGetApp().ShowImages() ? MyTreeCtrl::TreeCtrlIcon_File : -1;
|
||||
m_treeCtrl->InsertItem(m_treeCtrl->GetRootItem(), image, "2nd item");
|
||||
}
|
||||
|
||||
void MyFrame::OnAddItem(wxCommandEvent& WXUNUSED(event))
|
||||
@ -484,49 +506,59 @@ MyTreeCtrl::MyTreeCtrl(wxWindow *parent, const wxWindowID id,
|
||||
long style)
|
||||
: wxTreeCtrl(parent, id, pos, size, style)
|
||||
{
|
||||
#ifndef NO_VARIABLE_HEIGHT
|
||||
#if wxUSE_LIBJPEG
|
||||
wxImage::AddHandler(new wxJPEGHandler);
|
||||
wxImage image;
|
||||
|
||||
image.LoadFile(wxString("horse.jpg"), wxBITMAP_TYPE_JPEG );
|
||||
#endif
|
||||
#endif
|
||||
|
||||
m_reverseSort = FALSE;
|
||||
|
||||
CreateImageList();
|
||||
|
||||
// Add some items to the tree
|
||||
AddTestItemsToTree(3, 2);
|
||||
}
|
||||
|
||||
void MyTreeCtrl::CreateImageList(int size)
|
||||
{
|
||||
delete m_imageListNormal;
|
||||
|
||||
if ( size == -1 )
|
||||
{
|
||||
m_imageListNormal = NULL;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Make an image list containing small icons
|
||||
m_imageListNormal = new wxImageList(16, 16, TRUE);
|
||||
m_imageListNormal = new wxImageList(size, size, TRUE);
|
||||
|
||||
// should correspond to TreeCtrlIcon_xxx enum
|
||||
#if defined(__WXMSW__) && defined(__WIN16__)
|
||||
// This is required in 16-bit Windows mode only because we can't load a specific (16x16)
|
||||
// icon image, so it comes out stretched
|
||||
# ifndef NO_VARIABLE_HEIGHT
|
||||
m_imageListNormal->Add(image.ConvertToBitmap());
|
||||
# else
|
||||
m_imageListNormal->Add(wxBitmap("bitmap1", wxBITMAP_TYPE_BMP_RESOURCE));
|
||||
# endif
|
||||
m_imageListNormal->Add(wxBitmap("bitmap2", wxBITMAP_TYPE_BMP_RESOURCE));
|
||||
m_imageListNormal->Add(wxBitmap("bitmap3", wxBITMAP_TYPE_BMP_RESOURCE));
|
||||
m_imageListNormal->Add(wxBitmap("bitmap4", wxBITMAP_TYPE_BMP_RESOURCE));
|
||||
m_imageListNormal->Add(wxBitmap("bitmap5", wxBITMAP_TYPE_BMP_RESOURCE));
|
||||
#else
|
||||
# ifndef NO_VARIABLE_HEIGHT
|
||||
m_imageListNormal->Add(image.ConvertToBitmap());
|
||||
# else
|
||||
m_imageListNormal->Add(wxICON(icon1));
|
||||
# endif
|
||||
m_imageListNormal->Add(wxICON(icon2));
|
||||
m_imageListNormal->Add(wxICON(icon3));
|
||||
m_imageListNormal->Add(wxICON(icon4));
|
||||
m_imageListNormal->Add(wxICON(icon5));
|
||||
wxIcon icons[5];
|
||||
icons[0] = wxICON(icon1);
|
||||
icons[1] = wxICON(icon2);
|
||||
icons[2] = wxICON(icon3);
|
||||
icons[3] = wxICON(icon4);
|
||||
icons[4] = wxICON(icon5);
|
||||
|
||||
int sizeOrig = icons[0].GetWidth();
|
||||
for ( size_t i = 0; i < WXSIZEOF(icons); i++ )
|
||||
{
|
||||
if ( size == sizeOrig )
|
||||
{
|
||||
m_imageListNormal->Add(icons[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_imageListNormal->Add(wxImage(icons[i]).Rescale(size, size).
|
||||
ConvertToBitmap());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
SetImageList(m_imageListNormal);
|
||||
|
||||
// Add some items to the tree
|
||||
AddTestItemsToTree(3, 2);
|
||||
}
|
||||
|
||||
MyTreeCtrl::~MyTreeCtrl()
|
||||
@ -568,12 +600,21 @@ void MyTreeCtrl::AddItemsRecursively(const wxTreeItemId& idParent,
|
||||
|
||||
// here we pass to AppendItem() normal and selected item images (we
|
||||
// suppose that selected image follows the normal one in the enum)
|
||||
int image = depth == 1 ? TreeCtrlIcon_File : TreeCtrlIcon_Folder;
|
||||
wxTreeItemId id = AppendItem(idParent, str, image, image + 1,
|
||||
int image, imageSel;
|
||||
if ( wxGetApp().ShowImages() )
|
||||
{
|
||||
image = depth == 1 ? TreeCtrlIcon_File : TreeCtrlIcon_Folder;
|
||||
imageSel = image + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
image = imageSel = -1;
|
||||
}
|
||||
wxTreeItemId id = AppendItem(idParent, str, image, imageSel,
|
||||
new MyTreeItemData(str));
|
||||
|
||||
// and now we also set the expanded one (only for the folders)
|
||||
if ( hasChildren )
|
||||
if ( hasChildren && wxGetApp().ShowImages() )
|
||||
{
|
||||
SetItemImage(id, TreeCtrlIcon_FolderOpened,
|
||||
wxTreeItemIcon_Expanded);
|
||||
@ -594,10 +635,14 @@ void MyTreeCtrl::AddItemsRecursively(const wxTreeItemId& idParent,
|
||||
void MyTreeCtrl::AddTestItemsToTree(size_t numChildren,
|
||||
size_t depth)
|
||||
{
|
||||
int image = wxGetApp().ShowImages() ? MyTreeCtrl::TreeCtrlIcon_Folder : -1;
|
||||
wxTreeItemId rootId = AddRoot("Root",
|
||||
TreeCtrlIcon_Folder, TreeCtrlIcon_Folder,
|
||||
image, image,
|
||||
new MyTreeItemData("Root item"));
|
||||
SetItemImage(rootId, TreeCtrlIcon_FolderOpened, wxTreeItemIcon_Expanded);
|
||||
if ( image != -1 )
|
||||
{
|
||||
SetItemImage(rootId, TreeCtrlIcon_FolderOpened, wxTreeItemIcon_Expanded);
|
||||
}
|
||||
|
||||
AddItemsRecursively(rootId, numChildren, depth, 0);
|
||||
|
||||
@ -714,7 +759,8 @@ void MyTreeCtrl::OnEndDrag(wxTreeEvent& event)
|
||||
//
|
||||
// Finally, we only copy one item here but we might copy the entire tree if
|
||||
// we were dragging a folder.
|
||||
AppendItem(itemDst, text, TreeCtrlIcon_File);
|
||||
int image = wxGetApp().ShowImages() ? TreeCtrlIcon_File : -1;
|
||||
AppendItem(itemDst, text, image);
|
||||
}
|
||||
|
||||
void MyTreeCtrl::OnBeginLabelEdit(wxTreeEvent& event)
|
||||
|
@ -13,7 +13,15 @@
|
||||
class MyApp : public wxApp
|
||||
{
|
||||
public:
|
||||
MyApp() { m_showImages = TRUE; }
|
||||
|
||||
bool OnInit();
|
||||
|
||||
void SetShowImages(bool show) { m_showImages = show; }
|
||||
bool ShowImages() const { return m_showImages; }
|
||||
|
||||
private:
|
||||
bool m_showImages;
|
||||
};
|
||||
|
||||
class MyTreeItemData : public wxTreeItemData
|
||||
@ -66,6 +74,8 @@ public:
|
||||
|
||||
void GetItemsRecursively(const wxTreeItemId& idParent, long cookie);
|
||||
|
||||
void CreateImageList(int size = 32);
|
||||
|
||||
void AddTestItemsToTree(size_t numChildren, size_t depth);
|
||||
|
||||
void DoSortChildren(const wxTreeItemId& item, bool reverse = FALSE)
|
||||
@ -125,7 +135,10 @@ public:
|
||||
void OnDelete(wxCommandEvent& event);
|
||||
void OnDeleteChildren(wxCommandEvent& event);
|
||||
void OnDeleteAll(wxCommandEvent& event);
|
||||
|
||||
void OnRecreate(wxCommandEvent& event);
|
||||
void OnToggleImages(wxCommandEvent& event);
|
||||
void OnSetImageSize(wxCommandEvent& event);
|
||||
void OnCollapseAndReset(wxCommandEvent& event);
|
||||
|
||||
void OnSetBold(wxCommandEvent& WXUNUSED(event)) { DoSetBold(TRUE); }
|
||||
@ -184,6 +197,8 @@ enum
|
||||
TreeTest_DeleteChildren,
|
||||
TreeTest_DeleteAll,
|
||||
TreeTest_Recreate,
|
||||
TreeTest_ToggleImages,
|
||||
TreeTest_SetImageSize,
|
||||
TreeTest_ToggleSel,
|
||||
TreeTest_CollapseAndReset,
|
||||
TreeTest_EnsureVisible,
|
||||
|
@ -224,11 +224,16 @@ long wxGetUTCTime()
|
||||
|
||||
if (t0 != (time_t)-1 )
|
||||
return (long)difftime(t1, t0) + (60 * 60 * 24 * 4);
|
||||
wxLogSysError(_("Failed 2nd mktime"));
|
||||
wxLogSysError(_("mktime() failed"));
|
||||
}
|
||||
else
|
||||
{
|
||||
wxLogSysError(_("gmtime() failed"));
|
||||
}
|
||||
wxLogSysError(_("Failed gmtime"));
|
||||
}
|
||||
wxLogSysError(_("Failed to get the UTC system time"));
|
||||
|
||||
wxLogError(_("Failed to get the UTC system time."));
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -248,14 +253,15 @@ wxLongLong wxGetLocalTimeMillis()
|
||||
val *= tp.tv_sec;
|
||||
return (val + (tp.tv_usec / 1000));
|
||||
}
|
||||
return 0;
|
||||
return 0;
|
||||
#elif defined(HAVE_FTIME)
|
||||
struct timeb tp;
|
||||
if ( ftime(&tp) == 0 )
|
||||
{
|
||||
val *= tp.time;
|
||||
return (val + tp.millitm);
|
||||
}
|
||||
|
||||
// ftime() is void and not int in some mingw32 headers, so don't test the
|
||||
// return code (well, it shouldn't fail anyhow...)
|
||||
(void)ftime(&tp);
|
||||
val *= tp.time;
|
||||
return (val + tp.millitm);
|
||||
#else
|
||||
// We use wxGetLocalTime() to get the seconds since
|
||||
// 00:00:00 Jan 1st 1970 and then whatever is available
|
||||
@ -279,6 +285,5 @@ wxLongLong wxGetLocalTimeMillis()
|
||||
#endif
|
||||
|
||||
return val;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
@ -1496,10 +1496,12 @@ void wxTreeCtrl::SetImageList(wxImageList *imageList)
|
||||
{
|
||||
m_imageListNormal = imageList;
|
||||
|
||||
if ( !m_imageListNormal )
|
||||
return;
|
||||
|
||||
// Calculate a m_lineHeight value from the image sizes.
|
||||
// May be toggle off. Then wxTreeCtrl will spread when
|
||||
// necessary (which might look ugly).
|
||||
#if 1
|
||||
wxClientDC dc(this);
|
||||
m_lineHeight = (int)(dc.GetCharHeight() + 4);
|
||||
int width = 0, height = 0,
|
||||
@ -1515,7 +1517,6 @@ void wxTreeCtrl::SetImageList(wxImageList *imageList)
|
||||
m_lineHeight += 2; // at least 2 pixels
|
||||
else
|
||||
m_lineHeight += m_lineHeight/10; // otherwise 10% extra spacing
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxTreeCtrl::SetStateImageList(wxImageList *imageList)
|
||||
@ -1571,8 +1572,15 @@ void wxTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc)
|
||||
int image = item->GetCurrentImage();
|
||||
if ( image != NO_IMAGE )
|
||||
{
|
||||
m_imageListNormal->GetSize( image, image_w, image_h );
|
||||
image_w += 4;
|
||||
if ( m_imageListNormal )
|
||||
{
|
||||
m_imageListNormal->GetSize( image, image_w, image_h );
|
||||
image_w += 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
image = NO_IMAGE;
|
||||
}
|
||||
}
|
||||
|
||||
int total_h = GetLineHeight(item);
|
||||
@ -2062,8 +2070,15 @@ void wxTreeCtrl::Edit( const wxTreeItemId& item )
|
||||
int image = m_currentEdit->GetCurrentImage();
|
||||
if ( image != NO_IMAGE )
|
||||
{
|
||||
m_imageListNormal->GetSize( image, image_w, image_h );
|
||||
image_w += 4;
|
||||
if ( m_imageListNormal )
|
||||
{
|
||||
m_imageListNormal->GetSize( image, image_w, image_h );
|
||||
image_w += 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
wxFAIL_MSG(_T("you must create an image list to use images!"));
|
||||
}
|
||||
}
|
||||
x += image_w;
|
||||
w -= image_w + 4; // I don't know why +4 is needed
|
||||
@ -2304,8 +2319,11 @@ void wxTreeCtrl::CalculateSize( wxGenericTreeItem *item, wxDC &dc )
|
||||
int image = item->GetCurrentImage();
|
||||
if ( image != NO_IMAGE )
|
||||
{
|
||||
m_imageListNormal->GetSize( image, image_w, image_h );
|
||||
image_w += 4;
|
||||
if ( m_imageListNormal )
|
||||
{
|
||||
m_imageListNormal->GetSize( image, image_w, image_h );
|
||||
image_w += 4;
|
||||
}
|
||||
}
|
||||
|
||||
int total_h = (image_h > text_h) ? image_h : text_h;
|
||||
|
@ -1,4 +1,4 @@
|
||||
# This file was automatically generated by tmake at 20:56, 2000/03/01
|
||||
# This file was automatically generated by tmake at 08:59, 2000/03/03
|
||||
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE GTK.T!
|
||||
ALL_SOURCES = \
|
||||
generic/busyinfo.cpp \
|
||||
@ -222,19 +222,7 @@ ALL_SOURCES = \
|
||||
html/m_meta.cpp \
|
||||
html/m_pre.cpp \
|
||||
html/m_tables.cpp \
|
||||
html/winpars.cpp \
|
||||
ogl/basic.cpp \
|
||||
ogl/basic2.cpp \
|
||||
ogl/bmpshape.cpp \
|
||||
ogl/canvas.cpp \
|
||||
ogl/composit.cpp \
|
||||
ogl/constrnt.cpp \
|
||||
ogl/divided.cpp \
|
||||
ogl/drawn.cpp \
|
||||
ogl/lines.cpp \
|
||||
ogl/mfutils.cpp \
|
||||
ogl/ogldiag.cpp \
|
||||
ogl/oglmisc.cpp
|
||||
html/winpars.cpp
|
||||
|
||||
ALL_HEADERS = \
|
||||
accel.h \
|
||||
@ -552,21 +540,6 @@ ALL_HEADERS = \
|
||||
html/htmprint.h \
|
||||
html/m_templ.h \
|
||||
html/winpars.h \
|
||||
ogl/basic.h \
|
||||
ogl/basicp.h \
|
||||
ogl/bmpshape.h \
|
||||
ogl/canvas.h \
|
||||
ogl/composit.h \
|
||||
ogl/constrnt.h \
|
||||
ogl/divided.h \
|
||||
ogl/drawn.h \
|
||||
ogl/drawnp.h \
|
||||
ogl/lines.h \
|
||||
ogl/linesp.h \
|
||||
ogl/mfutils.h \
|
||||
ogl/misc.h \
|
||||
ogl/ogl.h \
|
||||
ogl/ogldiag.h \
|
||||
protocol/file.h \
|
||||
protocol/ftp.h \
|
||||
protocol/http.h \
|
||||
@ -1038,31 +1011,3 @@ HTMLDEPS = \
|
||||
m_tables.d \
|
||||
winpars.d
|
||||
|
||||
OGLOBJS = \
|
||||
basic.o \
|
||||
basic2.o \
|
||||
bmpshape.o \
|
||||
canvas.o \
|
||||
composit.o \
|
||||
constrnt.o \
|
||||
divided.o \
|
||||
drawn.o \
|
||||
lines.o \
|
||||
mfutils.o \
|
||||
ogldiag.o \
|
||||
oglmisc.o
|
||||
|
||||
OGLDEPS = \
|
||||
basic.d \
|
||||
basic2.d \
|
||||
bmpshape.d \
|
||||
canvas.d \
|
||||
composit.d \
|
||||
constrnt.d \
|
||||
divided.d \
|
||||
drawn.d \
|
||||
lines.d \
|
||||
mfutils.d \
|
||||
ogldiag.d \
|
||||
oglmisc.d
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
# This file was automatically generated by tmake at 20:56, 2000/03/01
|
||||
# This file was automatically generated by tmake at 08:59, 2000/03/03
|
||||
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE GTK.T!
|
||||
ALL_SOURCES = \
|
||||
generic/busyinfo.cpp \
|
||||
@ -222,19 +222,7 @@ ALL_SOURCES = \
|
||||
html/m_meta.cpp \
|
||||
html/m_pre.cpp \
|
||||
html/m_tables.cpp \
|
||||
html/winpars.cpp \
|
||||
ogl/basic.cpp \
|
||||
ogl/basic2.cpp \
|
||||
ogl/bmpshape.cpp \
|
||||
ogl/canvas.cpp \
|
||||
ogl/composit.cpp \
|
||||
ogl/constrnt.cpp \
|
||||
ogl/divided.cpp \
|
||||
ogl/drawn.cpp \
|
||||
ogl/lines.cpp \
|
||||
ogl/mfutils.cpp \
|
||||
ogl/ogldiag.cpp \
|
||||
ogl/oglmisc.cpp
|
||||
html/winpars.cpp
|
||||
|
||||
ALL_HEADERS = \
|
||||
accel.h \
|
||||
@ -552,21 +540,6 @@ ALL_HEADERS = \
|
||||
html/htmprint.h \
|
||||
html/m_templ.h \
|
||||
html/winpars.h \
|
||||
ogl/basic.h \
|
||||
ogl/basicp.h \
|
||||
ogl/bmpshape.h \
|
||||
ogl/canvas.h \
|
||||
ogl/composit.h \
|
||||
ogl/constrnt.h \
|
||||
ogl/divided.h \
|
||||
ogl/drawn.h \
|
||||
ogl/drawnp.h \
|
||||
ogl/lines.h \
|
||||
ogl/linesp.h \
|
||||
ogl/mfutils.h \
|
||||
ogl/misc.h \
|
||||
ogl/ogl.h \
|
||||
ogl/ogldiag.h \
|
||||
protocol/file.h \
|
||||
protocol/ftp.h \
|
||||
protocol/http.h \
|
||||
@ -1038,31 +1011,3 @@ HTMLDEPS = \
|
||||
m_tables.d \
|
||||
winpars.d
|
||||
|
||||
OGLOBJS = \
|
||||
basic.o \
|
||||
basic2.o \
|
||||
bmpshape.o \
|
||||
canvas.o \
|
||||
composit.o \
|
||||
constrnt.o \
|
||||
divided.o \
|
||||
drawn.o \
|
||||
lines.o \
|
||||
mfutils.o \
|
||||
ogldiag.o \
|
||||
oglmisc.o
|
||||
|
||||
OGLDEPS = \
|
||||
basic.d \
|
||||
basic2.d \
|
||||
bmpshape.d \
|
||||
canvas.d \
|
||||
composit.d \
|
||||
constrnt.d \
|
||||
divided.d \
|
||||
drawn.d \
|
||||
lines.d \
|
||||
mfutils.d \
|
||||
ogldiag.d \
|
||||
oglmisc.d
|
||||
|
||||
|
@ -97,7 +97,6 @@ static HTREEITEM GetItemFromPoint(HWND hwndTV, int x, int y)
|
||||
tvht.pt.x = x;
|
||||
tvht.pt.y = y;
|
||||
|
||||
// TreeView_HitTest() doesn't do the right cast in mingw32 headers
|
||||
return (HTREEITEM)TreeView_HitTest(hwndTV, &tvht);
|
||||
}
|
||||
|
||||
@ -152,7 +151,7 @@ static void SelectRange(HWND hwndTV,
|
||||
{
|
||||
// find the first (or last) item and select it
|
||||
bool cont = TRUE;
|
||||
HTREEITEM htItem = TreeView_GetRoot(hwndTV);
|
||||
HTREEITEM htItem = (HTREEITEM)TreeView_GetRoot(hwndTV);
|
||||
while ( htItem && cont )
|
||||
{
|
||||
if ( (htItem == htFirst) || (htItem == htLast) )
|
||||
@ -172,7 +171,7 @@ static void SelectRange(HWND hwndTV,
|
||||
}
|
||||
}
|
||||
|
||||
htItem = TreeView_GetNextVisible(hwndTV, htItem);
|
||||
htItem = (HTREEITEM)TreeView_GetNextVisible(hwndTV, htItem);
|
||||
}
|
||||
|
||||
// select the items in range
|
||||
@ -186,7 +185,7 @@ static void SelectRange(HWND hwndTV,
|
||||
|
||||
cont = (htItem != htFirst) && (htItem != htLast);
|
||||
|
||||
htItem = TreeView_GetNextVisible(hwndTV, htItem);
|
||||
htItem = (HTREEITEM)TreeView_GetNextVisible(hwndTV, htItem);
|
||||
}
|
||||
|
||||
// unselect the rest
|
||||
@ -199,7 +198,7 @@ static void SelectRange(HWND hwndTV,
|
||||
UnselectItem(hwndTV, htItem);
|
||||
}
|
||||
|
||||
htItem = TreeView_GetNextVisible(hwndTV, htItem);
|
||||
htItem = (HTREEITEM)TreeView_GetNextVisible(hwndTV, htItem);
|
||||
}
|
||||
}
|
||||
|
||||
@ -214,7 +213,7 @@ static void SelectRange(HWND hwndTV,
|
||||
static void SetFocus(HWND hwndTV, HTREEITEM htItem)
|
||||
{
|
||||
// the current focus
|
||||
HTREEITEM htFocus = TreeView_GetSelection(hwndTV);
|
||||
HTREEITEM htFocus = (HTREEITEM)TreeView_GetSelection(hwndTV);
|
||||
|
||||
if ( htItem )
|
||||
{
|
||||
@ -1838,7 +1837,7 @@ long wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
|
||||
// we handle.arrows and space, but not page up/down and home/end: the
|
||||
// latter should be easy, but not the former
|
||||
|
||||
HTREEITEM htSel = TreeView_GetSelection(GetHwnd());
|
||||
HTREEITEM htSel = (HTREEITEM)TreeView_GetSelection(GetHwnd());
|
||||
if ( !m_htSelStart )
|
||||
{
|
||||
m_htSelStart = (WXHTREEITEM)htSel;
|
||||
@ -1871,9 +1870,9 @@ long wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
|
||||
{
|
||||
(void)wxControl::MSWWindowProc(nMsg, wParam, lParam);
|
||||
|
||||
HTREEITEM htNext =
|
||||
wParam == VK_UP ? TreeView_GetPrevVisible(GetHwnd(), htSel)
|
||||
: TreeView_GetNextVisible(GetHwnd(), htSel);
|
||||
HTREEITEM htNext = (HTREEITEM)(wParam == VK_UP
|
||||
? TreeView_GetPrevVisible(GetHwnd(), htSel)
|
||||
: TreeView_GetNextVisible(GetHwnd(), htSel));
|
||||
|
||||
if ( !htNext )
|
||||
{
|
||||
|
@ -205,15 +205,37 @@ long wxExecute( const wxString& command, bool sync, wxProcess *process )
|
||||
return lRc;
|
||||
}
|
||||
|
||||
bool wxShell(const wxString& command)
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxShell
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
static wxString wxMakeShellCommand(const wxString& command)
|
||||
{
|
||||
wxString cmd;
|
||||
if ( !command )
|
||||
{
|
||||
// just an interactive shell
|
||||
cmd = _T("xterm");
|
||||
}
|
||||
else
|
||||
cmd = command;
|
||||
{
|
||||
// execute command in a shell
|
||||
cmd << _T("/bin/sh -c '") << command << _T('\'');
|
||||
}
|
||||
|
||||
return wxExecute(cmd) != 0;
|
||||
return cmd;
|
||||
}
|
||||
|
||||
bool wxShell(const wxString& command)
|
||||
{
|
||||
return wxExecute(wxMakeShellCommand(command), TRUE /* sync */) == 0;
|
||||
}
|
||||
|
||||
bool wxShell(const wxString& command, wxArrayString& output)
|
||||
{
|
||||
wxCHECK_MSG( !!command, FALSE, _T("can't exec shell non interactively") );
|
||||
|
||||
return wxExecute(wxMakeShellCommand(command), output);
|
||||
}
|
||||
|
||||
#if wxUSE_GUI
|
||||
|
Loading…
Reference in New Issue
Block a user