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