Removed GetExpandedProperties() (used to act as poor man's GetEditableState())
[wxWidgets.git] / samples / propgrid / tests.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: samples/propgrid/tests.cpp
3 // Purpose: wxPropertyGrid tests
4 // Author: Jaakko Salli
5 // Modified by:
6 // Created: 2007-05-16
7 // RCS-ID: $Id$
8 // Copyright: (c) Jaakko Salli
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 #include "wx/wxprec.h"
13
14 #ifdef __BORLANDC__
15 #pragma hdrstop
16 #endif
17
18 #ifndef WX_PRECOMP
19 #include "wx/wx.h"
20 #endif
21
22 #include <wx/propgrid/propgrid.h>
23 #include <wx/propgrid/advprops.h>
24 #include <wx/propgrid/manager.h>
25
26 #include "propgrid.h"
27 #include "sampleprops.h"
28
29
30 // -----------------------------------------------------------------------
31 // wxTestCustomFlagsProperty
32 // -----------------------------------------------------------------------
33
34 //
35 // Constant definitions required by wxFlagsProperty examples.
36 //
37
38 static const wxChar* _fs_framestyle_labels[] = {
39 wxT("wxCAPTION"),
40 wxT("wxMINIMIZE"),
41 wxT("wxMAXIMIZE"),
42 wxT("wxCLOSE_BOX"),
43 wxT("wxSTAY_ON_TOP"),
44 wxT("wxSYSTEM_MENU"),
45 wxT("wxRESIZE_BORDER"),
46 wxT("wxFRAME_TOOL_WINDOW"),
47 wxT("wxFRAME_NO_TASKBAR"),
48 wxT("wxFRAME_FLOAT_ON_PARENT"),
49 wxT("wxFRAME_SHAPED"),
50 (const wxChar*) NULL
51 };
52
53 static const long _fs_framestyle_values[] = {
54 wxCAPTION,
55 wxMINIMIZE,
56 wxMAXIMIZE,
57 wxCLOSE_BOX,
58 wxSTAY_ON_TOP,
59 wxSYSTEM_MENU,
60 wxRESIZE_BORDER,
61 wxFRAME_TOOL_WINDOW,
62 wxFRAME_NO_TASKBAR,
63 wxFRAME_FLOAT_ON_PARENT,
64 wxFRAME_SHAPED
65 };
66
67 // Colour labels. Last (before NULL, if any) must be Custom.
68 static const wxChar* mycolprop_labels[] = {
69 wxT("Black"),
70 wxT("Blue"),
71 wxT("Brown"),
72 wxT("Custom"),
73 (const wxChar*) NULL
74 };
75
76 // Relevant colour values as unsigned longs.
77 static unsigned long mycolprop_colours[] = {
78 wxPG_COLOUR(0,0,0),
79 wxPG_COLOUR(0,0,255),
80 wxPG_COLOUR(166,124,81),
81 wxPG_COLOUR(0,0,0)
82 };
83
84 // Implement property class. Third argument is optional values array,
85 // but in this example we are only interested in creating a shortcut
86 // for user to access the colour values. Last arg is itemcount, but
87 // it will be deprecated in the future.
88 WX_PG_DECLARE_CUSTOM_COLOUR_PROPERTY_USES_WXCOLOUR(wxMyColourProperty)
89 WX_PG_IMPLEMENT_CUSTOM_COLOUR_PROPERTY_USES_WXCOLOUR(wxMyColourProperty,
90 mycolprop_labels,
91 (long*)NULL,
92 mycolprop_colours)
93
94
95 WX_PG_DECLARE_CUSTOM_COLOUR_PROPERTY(wxMyColour2Property)
96 WX_PG_IMPLEMENT_CUSTOM_COLOUR_PROPERTY(wxMyColour2Property,
97 mycolprop_labels,
98 (long*)NULL,
99 mycolprop_colours)
100
101
102
103 // Just testing the macros
104 WX_PG_DECLARE_STRING_PROPERTY(wxTestStringProperty)
105 WX_PG_IMPLEMENT_STRING_PROPERTY(wxTestStringProperty,wxPG_NO_ESCAPE)
106 bool wxTestStringProperty::OnButtonClick( wxPropertyGrid*,
107 wxString& )
108 {
109 ::wxMessageBox(wxT("Button Clicked"));
110 return true;
111 }
112
113 WX_PG_DECLARE_STRING_PROPERTY(wxTextStringPropertyWithValidator)
114 WX_PG_IMPLEMENT_STRING_PROPERTY_WITH_VALIDATOR(wxTextStringPropertyWithValidator,
115 wxPG_NO_ESCAPE)
116
117 bool wxTextStringPropertyWithValidator::OnButtonClick( wxPropertyGrid* WXUNUSED(propgrid),
118 wxString& WXUNUSED(value) )
119 {
120 ::wxMessageBox(wxT("Button Clicked"));
121 return true;
122 }
123
124 wxValidator* wxTextStringPropertyWithValidator::DoGetValidator() const
125 {
126 #if wxUSE_VALIDATORS
127 WX_PG_DOGETVALIDATOR_ENTRY()
128 wxTextValidator* validator = new
129 wxTextValidator(wxFILTER_INCLUDE_CHAR_LIST);
130 wxArrayString oValid;
131 oValid.Add(wxT("0"));
132 oValid.Add(wxT("1"));
133 oValid.Add(wxT("2"));
134 oValid.Add(wxT("3"));
135 oValid.Add(wxT("4"));
136 oValid.Add(wxT("5"));
137 oValid.Add(wxT("6"));
138 oValid.Add(wxT("7"));
139 oValid.Add(wxT("8"));
140 oValid.Add(wxT("9"));
141 oValid.Add(wxT("$"));
142 validator->SetIncludes(oValid);
143 WX_PG_DOGETVALIDATOR_EXIT(validator)
144 #else
145 return NULL;
146 #endif
147 }
148
149 // -----------------------------------------------------------------------
150
151 //
152 // Test customizing wxColourProperty via subclassing
153 //
154 // * Includes custom colour entry.
155 // * Includes extra custom entry.
156 //
157 class MyColourProperty3 : public wxColourProperty
158 {
159 public:
160 MyColourProperty3( const wxString& label = wxPG_LABEL,
161 const wxString& name = wxPG_LABEL,
162 const wxColour& value = *wxWHITE )
163 : wxColourProperty(label, name, value)
164 {
165 wxPGChoices colours;
166 colours.Add(wxT("White"));
167 colours.Add(wxT("Black"));
168 colours.Add(wxT("Red"));
169 colours.Add(wxT("Green"));
170 colours.Add(wxT("Blue"));
171 colours.Add(wxT("Custom"));
172 colours.Add(wxT("None"));
173 m_choices = colours;
174 SetIndex(0);
175 wxVariant variant;
176 variant << value;
177 SetValue(variant);
178 }
179
180 virtual ~MyColourProperty3()
181 {
182 }
183
184 virtual wxColour GetColour( int index ) const
185 {
186 switch (index)
187 {
188 case 0: return *wxWHITE;
189 case 1: return *wxBLACK;
190 case 2: return *wxRED;
191 case 3: return *wxGREEN;
192 case 4: return *wxBLUE;
193 case 5:
194 // Return current colour for the custom entry
195 wxColour col;
196 if ( GetIndex() == GetCustomColourIndex() )
197 {
198 if ( m_value.IsNull() )
199 return col;
200 col << m_value;
201 return col;
202 }
203 return *wxWHITE;
204 };
205 return wxColour();
206 }
207
208 virtual wxString ColourToString( const wxColour& col, int index ) const
209 {
210 if ( index == (int)(m_choices.GetCount()-1) )
211 return wxT("");
212
213 return wxColourProperty::ColourToString(col, index);
214 }
215
216 virtual int GetCustomColourIndex() const
217 {
218 return m_choices.GetCount()-2;
219 }
220 };
221
222
223 void FormMain::AddTestProperties( wxPropertyGridPage* pg )
224 {
225 pg->Append( new wxMyColourProperty(wxT("CustomColourProperty1")) );
226
227 pg->SetPropertyHelpString(wxT("CustomColourProperty1"),
228 wxT("This is a wxMyColourProperty from the sample app. ")
229 wxT("It is built with WX_PG_IMPLEMENT_CUSTOM_COLOUR_PROPERTY_USES_WXCOLOUR macro ")
230 wxT("and has wxColour as its data type"));
231
232 pg->Append( new wxMyColour2Property(wxT("CustomColourProperty2")) );
233
234 pg->SetPropertyHelpString(wxT("CustomColourProperty2"),
235 wxT("This is a wxMyColour2Property from the sample app. ")
236 wxT("It is built with WX_PG_IMPLEMENT_CUSTOM_COLOUR_PROPERTY macro ")
237 wxT("and has wxColourPropertyValue as its data type"));
238
239 pg->Append( new MyColourProperty3(wxT("CustomColourProperty3"), wxPG_LABEL, *wxGREEN) );
240 pg->GetProperty(wxT("CustomColourProperty3"))->SetFlag(wxPG_PROP_AUTO_UNSPECIFIED);
241 pg->SetPropertyEditor( wxT("CustomColourProperty3"), wxPGEditor_ComboBox );
242
243 pg->SetPropertyHelpString(wxT("CustomColourProperty3"),
244 wxT("This is a MyColourProperty3 from the sample app. ")
245 wxT("It is built by subclassing wxColourProperty."));
246
247 pg->Append( new wxTextStringPropertyWithValidator(wxT("TestProp1"), wxPG_LABEL) );
248 }
249
250 // -----------------------------------------------------------------------
251
252 void FormMain::OnDumpList( wxCommandEvent& WXUNUSED(event) )
253 {
254 wxVariant values = m_pPropGridManager->GetPropertyValues(wxT("list"), wxNullProperty, wxPG_INC_ATTRIBUTES);
255 wxString text = wxT("This only tests that wxVariant related routines do not crash.");
256 wxString t;
257
258 wxDialog* dlg = new wxDialog(this,-1,wxT("wxVariant Test"),
259 wxDefaultPosition,wxDefaultSize,wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER);
260
261 unsigned int i;
262 for ( i = 0; i < (unsigned int)values.GetCount(); i++ )
263 {
264 wxVariant& v = values[i];
265
266 wxString strValue = v.GetString();
267
268 #if wxCHECK_VERSION(2,8,0)
269 if ( v.GetName().EndsWith(wxT("@attr")) )
270 #else
271 if ( v.GetName().Right(5) == wxT("@attr") )
272 #endif
273 {
274 text += wxString::Format(wxT("Attributes:\n"));
275
276 unsigned int n;
277 for ( n = 0; n < (unsigned int)v.GetCount(); n++ )
278 {
279 wxVariant& a = v[n];
280
281 t.Printf(wxT(" atribute %i: name=\"%s\" (type=\"%s\" value=\"%s\")\n"),(int)n,
282 a.GetName().c_str(),a.GetType().c_str(),a.GetString().c_str());
283 text += t;
284 }
285 }
286 else
287 {
288 t.Printf(wxT("%i: name=\"%s\" type=\"%s\" value=\"%s\"\n"),(int)i,
289 v.GetName().c_str(),v.GetType().c_str(),strValue.c_str());
290 text += t;
291 }
292 }
293
294 // multi-line text editor dialog
295 const int spacing = 8;
296 wxBoxSizer* topsizer = new wxBoxSizer( wxVERTICAL );
297 wxBoxSizer* rowsizer = new wxBoxSizer( wxHORIZONTAL );
298 wxTextCtrl* ed = new wxTextCtrl(dlg,11,text,
299 wxDefaultPosition,wxDefaultSize,wxTE_MULTILINE|wxTE_READONLY);
300 rowsizer->Add( ed, 1, wxEXPAND|wxALL, spacing );
301 topsizer->Add( rowsizer, 1, wxEXPAND, 0 );
302 rowsizer = new wxBoxSizer( wxHORIZONTAL );
303 const int butSzFlags =
304 wxALIGN_CENTRE_HORIZONTAL|wxALIGN_CENTRE_VERTICAL|wxBOTTOM|wxLEFT|wxRIGHT;
305 rowsizer->Add( new wxButton(dlg,wxID_OK,wxT("Ok")),
306 0, butSzFlags, spacing );
307 topsizer->Add( rowsizer, 0, wxALIGN_RIGHT|wxALIGN_CENTRE_VERTICAL, 0 );
308
309 dlg->SetSizer( topsizer );
310 topsizer->SetSizeHints( dlg );
311
312 dlg->SetSize(400,300);
313 dlg->Centre();
314 dlg->ShowModal();
315 }
316
317 // -----------------------------------------------------------------------
318
319 class TestRunner
320 {
321 public:
322
323 TestRunner( const wxString& name, wxPropertyGridManager* man, wxTextCtrl* ed, wxArrayString* errorMessages )
324 {
325 m_name = name;
326 m_man = man;
327 m_ed = ed;
328 m_errorMessages = errorMessages;
329 #ifdef __WXDEBUG__
330 m_preWarnings = wxPGGlobalVars->m_warnings;
331 #endif
332
333 if ( name != wxT("none") )
334 Msg(name+wxT("\n"));
335 }
336
337 ~TestRunner()
338 {
339 #ifdef __WXDEBUG__
340 int warningsOccurred = wxPGGlobalVars->m_warnings - m_preWarnings;
341 if ( warningsOccurred )
342 {
343 wxString s = wxString::Format(wxT("%i warnings occurred during test '%s'"), warningsOccurred, m_name.c_str());
344 m_errorMessages->push_back(s);
345 Msg(s);
346 }
347 #endif
348 }
349
350 void Msg( const wxString& text )
351 {
352 if ( m_ed )
353 {
354 m_ed->AppendText(text);
355 m_ed->AppendText(wxT("\n"));
356 }
357 wxLogDebug(text);
358 }
359
360 protected:
361 wxPropertyGridManager* m_man;
362 wxTextCtrl* m_ed;
363 wxArrayString* m_errorMessages;
364 wxString m_name;
365 #ifdef __WXDEBUG__
366 int m_preWarnings;
367 #endif
368 };
369
370
371 #define RT_START_TEST(TESTNAME) \
372 TestRunner tr(wxT(#TESTNAME), pgman, ed, &errorMessages);
373
374 #define RT_MSG(S) \
375 tr.Msg(S);
376
377 #define RT_FAILURE() \
378 { \
379 wxString s1 = wxString::Format(wxT("Test failure in tests.cpp, line %i."),__LINE__-1); \
380 errorMessages.push_back(s1); \
381 wxLogDebug(s1); \
382 failures++; \
383 }
384
385 #define RT_FAILURE_MSG(MSG) \
386 { \
387 wxString s1 = wxString::Format(wxT("Test failure in tests.cpp, line %i."),__LINE__-1); \
388 errorMessages.push_back(s1); \
389 wxLogDebug(s1); \
390 wxString s2 = wxString::Format(wxT("Message: %s"),MSG); \
391 errorMessages.push_back(s2); \
392 wxLogDebug(s2); \
393 failures++; \
394 }
395
396 #define RT_VALIDATE_VIRTUAL_HEIGHT(PROPS, EXTRATEXT) \
397 { \
398 unsigned int h1_ = PROPS->GetVirtualHeight(); \
399 unsigned int h2_ = PROPS->GetActualVirtualHeight(); \
400 if ( h1_ != h2_ ) \
401 { \
402 wxString s_ = wxString::Format(wxT("VirtualHeight = %i, should be %i (%s)"), h1_, h2_, EXTRATEXT.c_str()); \
403 RT_FAILURE_MSG(s_.c_str()); \
404 _failed_ = true; \
405 } \
406 else \
407 { \
408 _failed_ = false; \
409 } \
410 }
411
412
413 int gpiro_cmpfunc(const void* a, const void* b)
414 {
415 const wxPGProperty* p1 = (const wxPGProperty*) a;
416 const wxPGProperty* p2 = (const wxPGProperty*) b;
417 return (int) (((size_t)p1->GetClientData()) - ((size_t)p2->GetClientData()));
418 }
419
420 wxArrayPGProperty GetPropertiesInRandomOrder( wxPropertyGridInterface* props, int iterationFlags = wxPG_ITERATE_ALL )
421 {
422 wxArrayPGProperty arr;
423
424 wxPropertyGridIterator it;
425
426 for ( it = props->GetIterator(iterationFlags);
427 !it.AtEnd();
428 it++ )
429 {
430 wxPGProperty* p = *it;
431 size_t randomNumber = rand();
432 p->SetClientData(reinterpret_cast<void*>(randomNumber));
433 arr.push_back(p);
434 }
435
436 wxPGProperty** firstEntry = &arr[0];
437 qsort(firstEntry, arr.size(), sizeof(wxPGProperty*), gpiro_cmpfunc);
438
439 return arr;
440 }
441
442 bool FormMain::RunTests( bool fullTest, bool interactive )
443 {
444 wxString t;
445
446 wxPropertyGridManager* pgman = m_pPropGridManager;
447 wxPropertyGrid* pg;
448
449 size_t i;
450
451 pgman->ClearSelection();
452
453 int failures = 0;
454 bool _failed_ = false;
455 wxArrayString errorMessages;
456 wxDialog* dlg = NULL;
457
458 dlg = new wxDialog(this,-1,wxT("wxPropertyGrid Regression Tests"),
459 wxDefaultPosition,wxDefaultSize,wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER);
460
461 // multi-line text editor dialog
462 const int spacing = 8;
463 wxBoxSizer* topsizer = new wxBoxSizer( wxVERTICAL );
464 wxBoxSizer* rowsizer = new wxBoxSizer( wxHORIZONTAL );
465 wxTextCtrl* ed = new wxTextCtrl(dlg,11,wxEmptyString,
466 wxDefaultPosition,wxDefaultSize,wxTE_MULTILINE|wxTE_READONLY);
467 rowsizer->Add( ed, 1, wxEXPAND|wxALL, spacing );
468 topsizer->Add( rowsizer, 1, wxEXPAND, 0 );
469 rowsizer = new wxBoxSizer( wxHORIZONTAL );
470 const int butSzFlags =
471 wxALIGN_CENTRE_HORIZONTAL|wxALIGN_CENTRE_VERTICAL|wxBOTTOM|wxLEFT|wxRIGHT;
472 rowsizer->Add( new wxButton(dlg,wxID_OK,wxT("Ok")),
473 0, butSzFlags, spacing );
474 topsizer->Add( rowsizer, 0, wxALIGN_RIGHT|wxALIGN_CENTRE_VERTICAL, 0 );
475
476 dlg->SetSizer( topsizer );
477 topsizer->SetSizeHints( dlg );
478
479 dlg->SetSize(400,300);
480 dlg->Move(wxSystemSettings::GetMetric(wxSYS_SCREEN_X)-dlg->GetSize().x,
481 wxSystemSettings::GetMetric(wxSYS_SCREEN_Y)-dlg->GetSize().y);
482 dlg->Show();
483
484 {
485 //
486 // Basic iterator tests
487 RT_START_TEST(GetIterator)
488
489 wxPGVIterator it;
490 int count;
491
492 count = 0;
493 for ( it = pgman->GetVIterator(wxPG_ITERATE_PROPERTIES);
494 !it.AtEnd();
495 it.Next() )
496 {
497 wxPGProperty* p = it.GetProperty();
498 if ( p->IsCategory() )
499 RT_FAILURE_MSG(wxString::Format(wxT("'%s' is a category (non-private child property expected)"),p->GetLabel().c_str()).c_str())
500 else if ( p->GetParent()->HasFlag(wxPG_PROP_AGGREGATE) )
501 RT_FAILURE_MSG(wxString::Format(wxT("'%s' is a private child (non-private child property expected)"),p->GetLabel().c_str()).c_str())
502 count++;
503 }
504
505 RT_MSG(wxString::Format(wxT("GetVIterator(wxPG_ITERATE_PROPERTIES) -> %i entries"), count));
506
507 count = 0;
508 for ( it = pgman->GetVIterator(wxPG_ITERATE_CATEGORIES);
509 !it.AtEnd();
510 it.Next() )
511 {
512 wxPGProperty* p = it.GetProperty();
513 if ( !p->IsCategory() )
514 RT_FAILURE_MSG(wxString::Format(wxT("'%s' is not a category (only category was expected)"),p->GetLabel().c_str()).c_str())
515 count++;
516 }
517
518 RT_MSG(wxString::Format(wxT("GetVIterator(wxPG_ITERATE_CATEGORIES) -> %i entries"), count));
519
520 count = 0;
521 for ( it = pgman->GetVIterator(wxPG_ITERATE_PROPERTIES|wxPG_ITERATE_CATEGORIES);
522 !it.AtEnd();
523 it.Next() )
524 {
525 wxPGProperty* p = it.GetProperty();
526 if ( p->GetParent()->HasFlag(wxPG_PROP_AGGREGATE) )
527 RT_FAILURE_MSG(wxString::Format(wxT("'%s' is a private child (non-private child property or category expected)"),p->GetLabel().c_str()).c_str())
528 count++;
529 }
530
531 RT_MSG(wxString::Format(wxT("GetVIterator(wxPG_ITERATE_PROPERTIES|wxPG_ITERATE_CATEGORIES) -> %i entries"), count));
532
533 count = 0;
534 for ( it = pgman->GetVIterator(wxPG_ITERATE_VISIBLE);
535 !it.AtEnd();
536 it.Next() )
537 {
538 wxPGProperty* p = it.GetProperty();
539 if ( (p->GetParent() != p->GetParentState()->DoGetRoot() && !p->GetParent()->IsExpanded()) )
540 RT_FAILURE_MSG(wxString::Format(wxT("'%s' had collapsed parent (only visible properties expected)"),p->GetLabel().c_str()).c_str())
541 else if ( p->HasFlag(wxPG_PROP_HIDDEN) )
542 RT_FAILURE_MSG(wxString::Format(wxT("'%s' was hidden (only visible properties expected)"),p->GetLabel().c_str()).c_str())
543 count++;
544 }
545
546 RT_MSG(wxString::Format(wxT("GetVIterator(wxPG_ITERATE_VISIBLE) -> %i entries"), count));
547 }
548
549 if ( fullTest )
550 {
551 // Test that setting focus to properties does not crash things
552 RT_START_TEST(SelectProperty)
553
554 wxPropertyGridIterator it;
555 size_t ind;
556
557 for ( ind=0; ind<pgman->GetPageCount(); ind++ )
558 {
559 wxPropertyGridPage* page = pgman->GetPage(ind);
560 pgman->SelectPage(page);
561
562 for ( it = page->GetIterator(wxPG_ITERATE_VISIBLE);
563 !it.AtEnd();
564 it++ )
565 {
566 wxPGProperty* p = *it;
567 RT_MSG(p->GetLabel());
568 pgman->GetGrid()->SelectProperty(p, true);
569 ::wxMilliSleep(150);
570 Update();
571 }
572 }
573 }
574
575 {
576 //
577 // Delete everything in reverse order
578 RT_START_TEST(DeleteProperty)
579
580 wxPGVIterator it;
581 wxArrayPGProperty array;
582
583 for ( it = pgman->GetVIterator(wxPG_ITERATE_ALL&~(wxPG_IT_CHILDREN(wxPG_PROP_AGGREGATE)));
584 !it.AtEnd();
585 it.Next() )
586 array.push_back(it.GetProperty());
587
588 wxArrayPGProperty::reverse_iterator it2;
589
590 for ( it2 = array.rbegin(); it2 != array.rend(); it2++ )
591 {
592 wxPGProperty* p = (wxPGProperty*)*it2;
593 RT_MSG(wxString::Format(wxT("Deleting '%s' ('%s')"),p->GetLabel().c_str(),p->GetName().c_str()));
594 pgman->DeleteProperty(p);
595 }
596
597 // Recreate grid
598 CreateGrid( -1, -1 );
599 pgman = m_pPropGridManager;
600 }
601
602 {
603 //
604 // Test property default values
605 RT_START_TEST(Default_Values)
606
607 wxPGVIterator it;
608
609 for ( it = pgman->GetVIterator(wxPG_ITERATE_PROPERTIES);
610 !it.AtEnd();
611 it.Next() )
612 {
613 wxPGProperty* p = it.GetProperty();
614 pgman->SetPropertyValue(p, p->GetDefaultValue());
615 }
616
617 // Recreate grid
618 CreateGrid( -1, -1 );
619 pgman = m_pPropGridManager;
620 }
621
622 {
623 RT_START_TEST(GetPropertyValues)
624
625 for ( i=0; i<3; i++ )
626 {
627 wxString text;
628
629 wxPropertyGridPage* page = pgman->GetPage(i);
630
631 wxVariant values = page->GetPropertyValues();
632
633 unsigned int i;
634 for ( i = 0; i < (unsigned int)values.GetCount(); i++ )
635 {
636 wxVariant& v = values[i];
637
638 t.Printf(wxT("%i: name=\"%s\" type=\"%s\"\n"),(int)i,
639 v.GetName().c_str(),v.GetType().c_str());
640
641 text += t;
642 }
643 ed->AppendText(text);
644 }
645 }
646
647 {
648 RT_START_TEST(SetPropertyValue_and_GetPropertyValue)
649
650 // In this section, mixed up usage of wxT("propname") and "propname"
651 // in wxPropertyGridInterface functions is intentional.
652 // Purpose is to test wxPGPropArgCls ctors.
653
654 //pg = (wxPropertyGrid*) NULL;
655
656 wxArrayString test_arrstr_1;
657 test_arrstr_1.Add(wxT("Apple"));
658 test_arrstr_1.Add(wxT("Orange"));
659 test_arrstr_1.Add(wxT("Lemon"));
660
661 wxArrayString test_arrstr_2;
662 test_arrstr_2.Add(wxT("Potato"));
663 test_arrstr_2.Add(wxT("Cabbage"));
664 test_arrstr_2.Add(wxT("Cucumber"));
665
666 wxArrayInt test_arrint_1;
667 test_arrint_1.Add(1);
668 test_arrint_1.Add(2);
669 test_arrint_1.Add(3);
670
671 wxArrayInt test_arrint_2;
672 test_arrint_2.Add(0);
673 test_arrint_2.Add(1);
674 test_arrint_2.Add(4);
675
676 #if wxUSE_DATETIME
677 wxDateTime dt1 = wxDateTime::Now();
678 dt1.SetYear(dt1.GetYear()-1);
679
680 wxDateTime dt2 = wxDateTime::Now();
681 dt2.SetYear(dt2.GetYear()-10);
682 #endif
683
684 #define FLAG_TEST_SET1 (wxCAPTION|wxCLOSE_BOX|wxSYSTEM_MENU|wxRESIZE_BORDER)
685 #define FLAG_TEST_SET2 (wxSTAY_ON_TOP|wxCAPTION|wxICONIZE|wxSYSTEM_MENU)
686
687 pgman->SetPropertyValue(wxT("StringProperty"),wxT("Text1"));
688 pgman->SetPropertyValue(wxT("IntProperty"),1024);
689 pgman->SetPropertyValue(wxT("FloatProperty"),1024.0000000001);
690 pgman->SetPropertyValue(wxT("BoolProperty"),FALSE);
691 pgman->SetPropertyValue(wxT("EnumProperty"),120);
692 pgman->SetPropertyValue(wxT("ArrayStringProperty"),test_arrstr_1);
693 wxColour emptyCol;
694 pgman->SetPropertyValue(wxT("ColourProperty"),emptyCol);
695 pgman->SetPropertyValue(wxT("ColourProperty"),(wxObject*)wxBLACK);
696 pgman->SetPropertyValue(wxT("Size"),WXVARIANT(wxSize(150,150)));
697 pgman->SetPropertyValue(wxT("Position"),WXVARIANT(wxPoint(150,150)));
698 pgman->SetPropertyValue(wxT("MultiChoiceProperty"),test_arrint_1);
699 #if wxUSE_DATETIME
700 pgman->SetPropertyValue(wxT("DateProperty"),dt1);
701 #endif
702
703 pgman->SelectPage(2);
704 pg = pgman->GetGrid();
705
706 if ( pg->GetPropertyValueAsString(wxT("StringProperty")) != wxT("Text1") )
707 RT_FAILURE();
708 if ( pg->GetPropertyValueAsInt(wxT("IntProperty")) != 1024 )
709 RT_FAILURE();
710 if ( pg->GetPropertyValueAsDouble(wxT("FloatProperty")) != 1024.0000000001 )
711 RT_FAILURE();
712 if ( pg->GetPropertyValueAsBool(wxT("BoolProperty")) != FALSE )
713 RT_FAILURE();
714 if ( pg->GetPropertyValueAsLong(wxT("EnumProperty")) != 120 )
715 RT_FAILURE();
716 if ( pg->GetPropertyValueAsArrayString(wxT("ArrayStringProperty")) != test_arrstr_1 )
717 RT_FAILURE();
718 wxColour col;
719 col << pgman->GetPropertyValue(wxT("ColourProperty"));
720 if ( col != *wxBLACK )
721 RT_FAILURE();
722 if ( wxSizeRefFromVariant(pg->GetPropertyValue(wxT("Size"))) != wxSize(150,150) )
723 RT_FAILURE();
724 if ( wxPointRefFromVariant(pg->GetPropertyValue(wxT("Position"))) != wxPoint(150,150) )
725 RT_FAILURE();
726 if ( !(pg->GetPropertyValueAsArrayInt(wxT("MultiChoiceProperty")) == test_arrint_1) )
727 RT_FAILURE();
728 #if wxUSE_DATETIME
729 if ( !(pg->GetPropertyValueAsDateTime(wxT("DateProperty")) == dt1) )
730 RT_FAILURE();
731 #endif
732
733 pgman->SetPropertyValue(wxT("IntProperty"),wxLL(10000000000));
734 if ( pg->GetPropertyValueAsLongLong(wxT("IntProperty")) != wxLL(10000000000) )
735 RT_FAILURE();
736
737 pg->SetPropertyValue(wxT("StringProperty"),wxT("Text2"));
738 pg->SetPropertyValue(wxT("IntProperty"),512);
739 pg->SetPropertyValue(wxT("FloatProperty"),512.0);
740 pg->SetPropertyValue(wxT("BoolProperty"),TRUE);
741 pg->SetPropertyValue(wxT("EnumProperty"),80);
742 pg->SetPropertyValue(wxT("ArrayStringProperty"),test_arrstr_2);
743 pg->SetPropertyValue(wxT("ColourProperty"),(wxObject*)wxWHITE);
744 pg->SetPropertyValue(wxT("Size"),WXVARIANT(wxSize(300,300)));
745 pg->SetPropertyValue(wxT("Position"),WXVARIANT(wxPoint(300,300)));
746 pg->SetPropertyValue(wxT("MultiChoiceProperty"),test_arrint_2);
747 #if wxUSE_DATETIME
748 pg->SetPropertyValue(wxT("DateProperty"),dt2);
749 #endif
750
751 //pg = (wxPropertyGrid*) NULL;
752
753 pgman->SelectPage(0);
754
755 if ( pgman->GetPropertyValueAsString(wxT("StringProperty")) != wxT("Text2") )
756 RT_FAILURE();
757 if ( pgman->GetPropertyValueAsInt(wxT("IntProperty")) != 512 )
758 RT_FAILURE();
759 if ( pgman->GetPropertyValueAsDouble(wxT("FloatProperty")) != 512.0 )
760 RT_FAILURE();
761 if ( pgman->GetPropertyValueAsBool(wxT("BoolProperty")) != TRUE )
762 RT_FAILURE();
763 if ( pgman->GetPropertyValueAsLong(wxT("EnumProperty")) != 80 )
764 RT_FAILURE();
765 if ( pgman->GetPropertyValueAsArrayString(wxT("ArrayStringProperty")) != test_arrstr_2 )
766 RT_FAILURE();
767 col << pgman->GetPropertyValue(wxT("ColourProperty"));
768 if ( col != *wxWHITE )
769 RT_FAILURE();
770 if ( wxSizeRefFromVariant(pgman->GetPropertyValue(wxT("Size"))) != wxSize(300,300) )
771 RT_FAILURE();
772 if ( wxPointRefFromVariant(pgman->GetPropertyValue(wxT("Position"))) != wxPoint(300,300) )
773 RT_FAILURE();
774 if ( !(pgman->GetPropertyValueAsArrayInt(wxT("MultiChoiceProperty")) == test_arrint_2) )
775 RT_FAILURE();
776 #if wxUSE_DATETIME
777 if ( !(pgman->GetPropertyValueAsDateTime(wxT("DateProperty")) == dt2) )
778 RT_FAILURE();
779 #endif
780
781 pgman->SetPropertyValue(wxT("IntProperty"),wxLL(-80000000000));
782 if ( pgman->GetPropertyValueAsLongLong(wxT("IntProperty")) != wxLL(-80000000000) )
783 RT_FAILURE();
784
785 //
786 // Flexible wx(U)LongLong << operator safety conformance tests
787 wxPGProperty* prop;
788 wxLongLong ll;
789 wxULongLong ull;
790
791 prop = pgman->GetProperty(wxT("IntProperty"));
792 prop->SetValue(128);
793 ll << prop->GetValue();
794 if ( ll != 128 )
795 RT_FAILURE();
796
797 prop->SetValue(WXVARIANT(wxLL(68719476736)));
798 ll << prop->GetValue();
799 if ( ll.GetValue() != wxLL(68719476736) )
800 RT_FAILURE();
801
802 #if wxUSE_LONGLONG_NATIVE
803 wxLongLong_t ll_t;
804 ll_t << prop->GetValue();
805 if ( ll_t != wxLL(68719476736) )
806 RT_FAILURE();
807 #endif
808
809 prop->SetValue(256);
810 ll << prop->GetValue();
811 if ( ll != 256 )
812 RT_FAILURE();
813
814 prop = pgman->GetProperty(wxT("UIntProperty"));
815 prop->SetValue(128);
816 ull << prop->GetValue();
817 if ( ull != 128 )
818 RT_FAILURE();
819
820 prop->SetValue(WXVARIANT(wxULL(68719476739)));
821 ull << prop->GetValue();
822 if ( ull.GetValue() != wxULL(68719476739) )
823 RT_FAILURE();
824
825 #if wxUSE_LONGLONG_NATIVE
826 wxULongLong_t ull_t;
827 ull_t << prop->GetValue();
828 if ( ull_t != wxLL(68719476739) )
829 RT_FAILURE();
830 #endif
831
832 prop->SetValue(256);
833 ull << prop->GetValue();
834 if ( ull != 256 )
835 RT_FAILURE();
836
837 // Make sure children of composite parent get updated as well
838 // Original string value: "Lamborghini Diablo SV; 5707; [300; 3.9; 8.6] 300000"
839
840 //
841 // This updates children as well
842 wxString nvs = "Lamborghini Diablo XYZ; 5707; [100; 3.9; 8.6] 3000002";
843 pgman->SetPropertyValue("Car", nvs);
844
845 if ( pgman->GetPropertyValueAsString("Car.Model") != "Lamborghini Diablo XYZ" )
846 {
847 wxLogDebug("Did not match: Car.Model=%s", pgman->GetPropertyValueAsString("Car.Model").c_str());
848 RT_FAILURE();
849 }
850
851 if ( pgman->GetPropertyValueAsInt("Car.Speeds.Max. Speed (mph)") != 100 )
852 {
853 wxLogDebug("Did not match: Car.Speeds.Max. Speed (mph)=%s", pgman->GetPropertyValueAsString("Car.Speeds.Max. Speed (mph)").c_str());
854 RT_FAILURE();
855 }
856
857 if ( pgman->GetPropertyValueAsInt("Car.Price ($)") != 3000002 )
858 {
859 wxLogDebug("Did not match: Car.Price ($)=%s", pgman->GetPropertyValueAsString("Car.Price ($)").c_str());
860 RT_FAILURE();
861 }
862 }
863
864 {
865 RT_START_TEST(SetPropertyValueUnspecified)
866
867 // Null variant setter tests
868 pgman->SetPropertyValueUnspecified(wxT("StringProperty"));
869 pgman->SetPropertyValueUnspecified(wxT("IntProperty"));
870 pgman->SetPropertyValueUnspecified(wxT("FloatProperty"));
871 pgman->SetPropertyValueUnspecified(wxT("BoolProperty"));
872 pgman->SetPropertyValueUnspecified(wxT("EnumProperty"));
873 pgman->SetPropertyValueUnspecified(wxT("ArrayStringProperty"));
874 pgman->SetPropertyValueUnspecified(wxT("ColourProperty"));
875 pgman->SetPropertyValueUnspecified(wxT("Size"));
876 pgman->SetPropertyValueUnspecified(wxT("Position"));
877 pgman->SetPropertyValueUnspecified(wxT("MultiChoiceProperty"));
878 #if wxUSE_DATETIME
879 pgman->SetPropertyValueUnspecified(wxT("DateProperty"));
880 #endif
881 }
882
883 {
884 RT_START_TEST(Attributes)
885
886 wxPGProperty* prop = pgman->GetProperty(wxT("StringProperty"));
887 prop->SetAttribute(wxT("Dummy Attribute"), (long)15);
888
889 if ( prop->GetAttribute(wxT("Dummy Attribute")).GetLong() != 15 )
890 RT_FAILURE();
891
892 prop->SetAttribute(wxT("Dummy Attribute"), wxVariant());
893
894 if ( !prop->GetAttribute(wxT("Dummy Attribute")).IsNull() )
895 RT_FAILURE();
896 }
897
898 {
899 wxPropertyGridPage* page1;
900 wxPropertyGridPage* page2;
901 wxPropertyGridPage* page3;
902 wxVariant pg1_values;
903 wxVariant pg2_values;
904 wxVariant pg3_values;
905
906 {
907 RT_START_TEST(GetPropertyValues)
908
909 page1 = pgman->GetPage(0);
910 pg1_values = page1->GetPropertyValues(wxT("Page1"),NULL,wxPG_KEEP_STRUCTURE);
911 page2 = pgman->GetPage(1);
912 pg2_values = page2->GetPropertyValues(wxT("Page2"),NULL,wxPG_KEEP_STRUCTURE);
913 page3 = pgman->GetPage(2);
914 pg3_values = page3->GetPropertyValues(wxT("Page3"),NULL,wxPG_KEEP_STRUCTURE);
915 }
916
917 {
918 RT_START_TEST(SetPropertyValues)
919
920 page1->SetPropertyValues(pg3_values);
921 page2->SetPropertyValues(pg1_values);
922 page3->SetPropertyValues(pg2_values);
923 }
924 }
925
926 if ( !(pgman->GetWindowStyleFlag()&wxPG_HIDE_CATEGORIES) )
927 {
928 RT_START_TEST(Collapse_and_GetFirstCategory_and_GetNextCategory)
929
930 for ( i=0; i<3; i++ )
931 {
932 wxPropertyGridPage* page = pgman->GetPage(i);
933
934 wxPropertyGridIterator it;
935
936 for ( it = page->GetIterator( wxPG_ITERATE_CATEGORIES );
937 !it.AtEnd();
938 it++ )
939 {
940 wxPGProperty* p = *it;
941
942 if ( !page->IsPropertyCategory(p) )
943 RT_FAILURE();
944
945 page->Collapse( p );
946
947 t.Printf(wxT("Collapsing: %s\n"),page->GetPropertyLabel(p).c_str());
948 ed->AppendText(t);
949 }
950 }
951 }
952
953 {
954 RT_START_TEST(Save_And_RestoreEditableState)
955
956 for ( i=0; i<3; i++ )
957 {
958 pgman->SelectPage(i);
959
960 wxString stringState = pgman->SaveEditableState();
961 bool res = pgman->RestoreEditableState(stringState);
962 if ( !res )
963 RT_FAILURE();
964 }
965 }
966
967 //if ( !(pgman->GetWindowStyleFlag()&wxPG_HIDE_CATEGORIES) )
968 {
969 RT_START_TEST(Expand_and_GetFirstCategory_and_GetNextCategory)
970
971 for ( i=0; i<3; i++ )
972 {
973 wxPropertyGridPage* page = pgman->GetPage(i);
974
975 wxPropertyGridIterator it;
976
977 for ( it = page->GetIterator( wxPG_ITERATE_CATEGORIES );
978 !it.AtEnd();
979 it++ )
980 {
981 wxPGProperty* p = *it;
982
983 if ( !page->IsPropertyCategory(p) )
984 RT_FAILURE();
985
986 page->Expand( p );
987
988 t.Printf(wxT("Expand: %s\n"),page->GetPropertyLabel(p).c_str());
989 ed->AppendText(t);
990 }
991 }
992 }
993
994 {
995 RT_START_TEST(Choice_Manipulation)
996
997 wxPGProperty* enumProp = pgman->GetProperty(wxT("EnumProperty"));
998
999 pgman->SelectPage(2);
1000 pgman->SelectProperty(enumProp);
1001 wxASSERT(pgman->GetGrid()->GetSelection() == enumProp);
1002
1003 const wxPGChoices& choices = enumProp->GetChoices();
1004 int ind = enumProp->InsertChoice(wxT("New Choice"), choices.GetCount()/2);
1005 enumProp->DeleteChoice(ind);
1006
1007 // Recreate the original grid
1008 CreateGrid( -1, -1 );
1009 pgman = m_pPropGridManager;
1010 }
1011
1012 //if ( !(pgman->GetWindowStyleFlag()&wxPG_HIDE_CATEGORIES) )
1013 {
1014 RT_START_TEST(RandomCollapse)
1015
1016 // Select the most error prone page as visible.
1017 pgman->SelectPage(1);
1018
1019 for ( i=0; i<3; i++ )
1020 {
1021 wxArrayPtrVoid arr;
1022
1023 wxPropertyGridPage* page = pgman->GetPage(i);
1024
1025 wxPropertyGridIterator it;
1026
1027 for ( it = page->GetIterator( wxPG_ITERATE_CATEGORIES );
1028 !it.AtEnd();
1029 it++ )
1030 {
1031 arr.Add((void*)*it);
1032 }
1033
1034 if ( arr.GetCount() )
1035 {
1036 size_t n;
1037
1038 pgman->Collapse( (wxPGProperty*)arr.Item(0) );
1039
1040 for ( n=arr.GetCount()-1; n>0; n-- )
1041 {
1042 pgman->Collapse( (wxPGProperty*)arr.Item(n) );
1043 }
1044 }
1045
1046 }
1047 }
1048
1049 {
1050 RT_START_TEST(EnsureVisible)
1051 pgman->EnsureVisible(wxT("Cell Colour"));
1052 }
1053
1054 {
1055 RT_START_TEST(SetPropertyBackgroundColour)
1056 wxCommandEvent evt;
1057 evt.SetInt(1); // IsChecked() will return TRUE.
1058 evt.SetId(ID_COLOURSCHEME4);
1059 OnCatColours(evt);
1060 OnColourScheme(evt);
1061 }
1062
1063 {
1064 RT_START_TEST(ManagerClear)
1065 pgman->Clear();
1066
1067 if ( pgman->GetPageCount() )
1068 RT_FAILURE();
1069
1070 // Recreate the original grid
1071 CreateGrid( -1, -1 );
1072 pgman = m_pPropGridManager;
1073 }
1074
1075 /*
1076 {
1077 // TODO: This test fails.
1078 RT_START_TEST(SetSplitterPosition)
1079
1080 InitPanel();
1081
1082 const int trySplitterPos = 50;
1083
1084 int style = wxPG_AUTO_SORT; // wxPG_SPLITTER_AUTO_CENTER;
1085 pgman = m_pPropGridManager =
1086 new wxPropertyGridManager(m_panel, wxID_ANY,
1087 wxDefaultPosition,
1088 wxDefaultSize,
1089 style );
1090
1091 PopulateGrid();
1092 pgman->SetSplitterPosition(trySplitterPos);
1093
1094 if ( pgman->GetGrid()->GetSplitterPosition() != trySplitterPos )
1095 RT_FAILURE_MSG(wxString::Format(wxT("Splitter position was %i (should have been %i)"),(int)pgman->GetGrid()->GetSplitterPosition(),trySplitterPos).c_str());
1096
1097 m_topSizer->Add( m_pPropGridManager, 1, wxEXPAND );
1098 FinalizePanel();
1099
1100 wxSize sz = GetSize();
1101 wxSize origSz = sz;
1102 sz.x += 5;
1103 sz.y += 5;
1104
1105 if ( pgman->GetGrid()->GetSplitterPosition() != trySplitterPos )
1106 RT_FAILURE_MSG(wxString::Format(wxT("Splitter position was %i (should have been %i)"),(int)pgman->GetGrid()->GetSplitterPosition(),trySplitterPos).c_str());
1107
1108 SetSize(origSz);
1109
1110 // Recreate the original grid
1111 CreateGrid( -1, -1 );
1112 pgman = m_pPropGridManager;
1113 }
1114 */
1115
1116 {
1117 RT_START_TEST(HideProperty)
1118
1119 wxPropertyGridPage* page = pgman->GetPage(0);
1120
1121 srand(0x1234);
1122
1123 wxArrayPGProperty arr1;
1124
1125 arr1 = GetPropertiesInRandomOrder(page);
1126
1127 if ( !_failed_ )
1128 {
1129 for ( i=0; i<arr1.size(); i++ )
1130 {
1131 wxPGProperty* p = arr1[i];
1132 page->HideProperty(p, true);
1133
1134 wxString s = wxString::Format(wxT("HideProperty(%i, %s)"), i, p->GetLabel().c_str());
1135 RT_VALIDATE_VIRTUAL_HEIGHT(page, s)
1136 if ( _failed_ )
1137 break;
1138 }
1139 }
1140
1141 if ( !_failed_ )
1142 {
1143 wxArrayPGProperty arr2 = GetPropertiesInRandomOrder(page);
1144
1145 for ( i=0; i<arr2.size(); i++ )
1146 {
1147 wxPGProperty* p = arr2[i];
1148 page->HideProperty(p, false);
1149
1150 wxString s = wxString::Format(wxT("ShowProperty(%i, %s)"), i, p->GetLabel().c_str());
1151 RT_VALIDATE_VIRTUAL_HEIGHT(page, s)
1152 if ( _failed_ )
1153 break;
1154 }
1155 }
1156
1157 //
1158 // Let's do some more, for better consistency
1159 arr1 = GetPropertiesInRandomOrder(page);
1160
1161 if ( !_failed_ )
1162 {
1163 for ( i=0; i<arr1.size(); i++ )
1164 {
1165 wxPGProperty* p = arr1[i];
1166 page->HideProperty(p, true);
1167
1168 wxString s = wxString::Format(wxT("HideProperty(%i, %s)"), i, p->GetLabel().c_str());
1169 RT_VALIDATE_VIRTUAL_HEIGHT(page, s)
1170 if ( _failed_ )
1171 break;
1172 }
1173 }
1174
1175 if ( !_failed_ )
1176 {
1177 wxArrayPGProperty arr2 = GetPropertiesInRandomOrder(page);
1178
1179 for ( i=0; i<arr2.size(); i++ )
1180 {
1181 wxPGProperty* p = arr2[i];
1182 page->HideProperty(p, false);
1183
1184 wxString s = wxString::Format(wxT("ShowProperty(%i, %s)"), i, p->GetLabel().c_str());
1185 RT_VALIDATE_VIRTUAL_HEIGHT(page, s)
1186 if ( _failed_ )
1187 break;
1188 }
1189 }
1190
1191 //
1192 // Ok, this time only hide half of them
1193 arr1 = GetPropertiesInRandomOrder(page);
1194 arr1.resize(arr1.size()/2);
1195
1196 if ( !_failed_ )
1197 {
1198 for ( i=0; i<arr1.size(); i++ )
1199 {
1200 wxPGProperty* p = arr1[i];
1201 page->HideProperty(p, true);
1202
1203 wxString s = wxString::Format(wxT("HideProperty(%i, %s)"), i, p->GetLabel().c_str());
1204 RT_VALIDATE_VIRTUAL_HEIGHT(page, s)
1205 if ( _failed_ )
1206 break;
1207 }
1208 }
1209
1210 if ( !_failed_ )
1211 {
1212 wxArrayPGProperty arr2 = GetPropertiesInRandomOrder(page);
1213
1214 for ( i=0; i<arr2.size(); i++ )
1215 {
1216 wxPGProperty* p = arr2[i];
1217 page->HideProperty(p, false);
1218
1219 wxString s = wxString::Format(wxT("ShowProperty(%i, %s)"), i, p->GetLabel().c_str());
1220 RT_VALIDATE_VIRTUAL_HEIGHT(page, s)
1221 if ( _failed_ )
1222 break;
1223 }
1224 }
1225
1226 // Recreate the original grid
1227 CreateGrid( -1, -1 );
1228 pgman = m_pPropGridManager;
1229 }
1230
1231 if ( fullTest )
1232 {
1233 RT_START_TEST(MultipleColumns)
1234
1235 // Test with multiple columns
1236 // FIXME: Does not display changes.
1237 for ( i=3; i<12; i+=2 )
1238 {
1239 RT_MSG(wxString::Format(wxT("%i columns"),i));
1240 CreateGrid( -1, -1 );
1241 pgman = m_pPropGridManager;
1242 pgman->SetColumnCount(i);
1243 Refresh();
1244 Update();
1245 wxMilliSleep(500);
1246 }
1247 }
1248
1249 if ( fullTest )
1250 {
1251 RT_START_TEST(WindowStyles)
1252
1253 // Recreate grid with all possible (single) flags
1254 wxASSERT(wxPG_AUTO_SORT == 0x000000010);
1255
1256 for ( i=4; i<16; i++ )
1257 {
1258 int flag = 1<<i;
1259 RT_MSG(wxString::Format(wxT("Style: 0x%X"),flag));
1260 CreateGrid( flag, -1 );
1261 pgman = m_pPropGridManager;
1262 Update();
1263 wxMilliSleep(500);
1264 }
1265
1266 wxASSERT(wxPG_EX_INIT_NOCAT == 0x00001000);
1267
1268 for ( i=12; i<24; i++ )
1269 {
1270 int flag = 1<<i;
1271 RT_MSG(wxString::Format(wxT("ExStyle: 0x%X"),flag));
1272 CreateGrid( -1, flag );
1273 pgman = m_pPropGridManager;
1274 Update();
1275 wxMilliSleep(500);
1276 }
1277
1278 // Recreate the original grid
1279 CreateGrid( -1, -1 );
1280 pgman = m_pPropGridManager;
1281 }
1282
1283 RT_START_TEST(none)
1284
1285 bool retVal;
1286
1287 if ( failures || errorMessages.size() )
1288 {
1289 retVal = false;
1290
1291 wxString s;
1292 #ifdef __WXDEBUG__
1293 if ( failures )
1294 #endif
1295 s = wxString::Format(wxT("%i tests failed!!!"), failures);
1296 #ifdef __WXDEBUG__
1297 else
1298 s = wxString::Format(wxT("All tests were succesfull, but there were %i warnings!"), wxPGGlobalVars->m_warnings);
1299 #endif
1300 RT_MSG(s)
1301 for ( i=0; i<errorMessages.size(); i++ )
1302 RT_MSG(errorMessages[i])
1303 wxMessageBox(s, wxT("Some Tests Failed"));
1304 }
1305 else
1306 {
1307 RT_MSG(wxT("All tests succesfull"))
1308 retVal = true;
1309
1310 if ( !interactive )
1311 dlg->Close();
1312 }
1313
1314 pgman->SelectPage(0);
1315
1316 // Test may screw up the toolbar, so we need to refresh it.
1317 wxToolBar* toolBar = pgman->GetToolBar();
1318 if ( toolBar )
1319 toolBar->Refresh();
1320
1321 return retVal;
1322 }
1323
1324 // -----------------------------------------------------------------------