@class wxSystemSettings
wxSystemSettings allows the application to ask for details about the system.
- This can include settings such as standard colours, fonts,
- and user interface element sizes.
+
+ This can include settings such as standard colours, fonts, and user interface
+ element sizes.
@library{wxcore}
@category{cfg}
/**
Returns a system colour.
- @a index can be one of the ::wxSystemColour enum values.
+
+ @param index
+ Can be one of the ::wxSystemColour enum values.
+
+ @return
+ The returned colour is always valid.
*/
static wxColour GetColour(wxSystemColour index);
/**
Returns a system font.
- @a index can be one of the ::wxSystemFont enum values.
+
+ @param index
+ Can be one of the ::wxSystemFont enum values.
+
+ @return
+ The returned font is always valid.
*/
static wxFont GetFont(wxSystemFont index);
#endif
#include "wx/fontutil.h"
+#include "wx/fontenum.h"
#include <gtk/gtk.h>
#include "wx/gtk/private/win_gtk.h"
break;
}
+ wxASSERT(color.IsOk());
return color;
}
wxNativeFontInfo info;
info.description = ButtonStyle()->font_desc;
gs_fontSystem = wxFont(info);
+
+ // (try to) heal the default font (on some common systems e.g. Ubuntu
+ // it's "Sans Serif" but the real font is called "Sans"):
+ if (!wxFontEnumerator::IsValidFacename(gs_fontSystem.GetFaceName()) &&
+ gs_fontSystem.GetFaceName() == "Sans Serif")
+ gs_fontSystem.SetFaceName("Sans");
+
info.description = NULL;
}
font = gs_fontSystem;
default:
break;
}
+
+ wxASSERT(font.IsOk() && wxFontEnumerator::IsValidFacename(font.GetFaceName()));
+
return font;
}
#endif
#include "wx/fontutil.h"
+#include "wx/fontenum.h"
// ----------------------------------------------------------------------------
// private classes
colSys = ::GetSysColor(index);
#endif
}
-
- return wxRGBToColour(colSys);
+
+ wxColour ret = wxRGBToColour(colSys);
+ wxASSERT(ret.IsOk());
+ return ret;
}
// ----------------------------------------------------------------------------
gs_fontDefault = new wxFont(wxCreateFontFromStockObject(SYSTEM_FONT));
}
+ wxASSERT(gs_fontDefault->IsOk() &&
+ wxFontEnumerator::IsValidFacename(gs_fontDefault->GetFaceName()));
return *gs_fontDefault;
#else // !__WXWINCE__
// wxWindow ctor calls GetFont(wxSYS_DEFAULT_GUI_FONT) so we're
gs_fontDefault = new wxFont(font);
}
+ wxASSERT(font.IsOk() && wxFontEnumerator::IsValidFacename(font.GetFaceName()));
return font;
#endif // __WXWINCE__/!__WXWINCE__
}
#endif
#include "wx/osx/private.h"
+#include "wx/fontenum.h"
// ----------------------------------------------------------------------------
// wxSystemSettingsNative
break ;
}
+ //wxASSERT(resultColor.IsOk());
+
return resultColor;
}
wxFont wxSystemSettingsNative::GetFont(wxSystemFont index)
{
+ wxFont font;
+
switch (index)
{
case wxSYS_ANSI_VAR_FONT :
case wxSYS_SYSTEM_FONT :
case wxSYS_DEVICE_DEFAULT_FONT :
case wxSYS_DEFAULT_GUI_FONT :
- return *wxSMALL_FONT ;
+ font = *wxSMALL_FONT ;
break ;
default :
+ font = *wxNORMAL_FONT ;
break ;
}
- return *wxNORMAL_FONT;
+ //wxASSERT(font.IsOk() && wxFontEnumerator::IsValidFacename(font.GetFaceName()));
+
+ return font;
}
// ----------------------------------------------------------------------------
test_gui_guifuncs.o \
test_gui_selstoretest.o \
test_gui_garbage.o \
+ test_gui_settings.o \
test_gui_socket.o \
test_gui_clientsize.o \
test_gui_setsize.o
test_gui_garbage.o: $(srcdir)/misc/garbage.cpp $(TEST_GUI_ODEP)
$(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/misc/garbage.cpp
+test_gui_settings.o: $(srcdir)/misc/settings.cpp $(TEST_GUI_ODEP)
+ $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/misc/settings.cpp
+
test_gui_socket.o: $(srcdir)/net/socket.cpp $(TEST_GUI_ODEP)
$(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/net/socket.cpp
$(OBJS)\test_gui_guifuncs.obj \
$(OBJS)\test_gui_selstoretest.obj \
$(OBJS)\test_gui_garbage.obj \
+ $(OBJS)\test_gui_settings.obj \
$(OBJS)\test_gui_socket.obj \
$(OBJS)\test_gui_clientsize.obj \
$(OBJS)\test_gui_setsize.obj
$(OBJS)\test_gui_garbage.obj: .\misc\garbage.cpp
$(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\misc\garbage.cpp
+$(OBJS)\test_gui_settings.obj: .\misc\settings.cpp
+ $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\misc\settings.cpp
+
$(OBJS)\test_gui_socket.obj: .\net\socket.cpp
$(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\net\socket.cpp
$(OBJS)\test_gui_guifuncs.o \
$(OBJS)\test_gui_selstoretest.o \
$(OBJS)\test_gui_garbage.o \
+ $(OBJS)\test_gui_settings.o \
$(OBJS)\test_gui_socket.o \
$(OBJS)\test_gui_clientsize.o \
$(OBJS)\test_gui_setsize.o
$(OBJS)\test_gui_garbage.o: ./misc/garbage.cpp
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
+$(OBJS)\test_gui_settings.o: ./misc/settings.cpp
+ $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
+
$(OBJS)\test_gui_socket.o: ./net/socket.cpp
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\test_gui_guifuncs.obj \
$(OBJS)\test_gui_selstoretest.obj \
$(OBJS)\test_gui_garbage.obj \
+ $(OBJS)\test_gui_settings.obj \
$(OBJS)\test_gui_socket.obj \
$(OBJS)\test_gui_clientsize.obj \
$(OBJS)\test_gui_setsize.obj
$(OBJS)\test_gui_garbage.obj: .\misc\garbage.cpp
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\misc\garbage.cpp
+$(OBJS)\test_gui_settings.obj: .\misc\settings.cpp
+ $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\misc\settings.cpp
+
$(OBJS)\test_gui_socket.obj: .\net\socket.cpp
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\net\socket.cpp
$(OBJS)\test_gui_guifuncs.obj &
$(OBJS)\test_gui_selstoretest.obj &
$(OBJS)\test_gui_garbage.obj &
+ $(OBJS)\test_gui_settings.obj &
$(OBJS)\test_gui_socket.obj &
$(OBJS)\test_gui_clientsize.obj &
$(OBJS)\test_gui_setsize.obj
$(OBJS)\test_gui_garbage.obj : .AUTODEPEND .\misc\garbage.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<
+$(OBJS)\test_gui_settings.obj : .AUTODEPEND .\misc\settings.cpp
+ $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<
+
$(OBJS)\test_gui_socket.obj : .AUTODEPEND .\net\socket.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////
+// Name: tests/misc/settings.cpp
+// Purpose: test wxSettings
+// Author: Francesco Montorsi
+// Created: 2009-03-24
+// RCS-ID: $Id$
+// Copyright: (c) 2009 Francesco Montorsi
+///////////////////////////////////////////////////////////////////////////////
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
+#include "testprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+#include "wx/settings.h"
+#include "wx/fontenum.h"
+
+// ----------------------------------------------------------------------------
+// test class
+// ----------------------------------------------------------------------------
+
+class SettingsTestCase : public CppUnit::TestCase
+{
+public:
+ SettingsTestCase() { }
+
+private:
+ CPPUNIT_TEST_SUITE( SettingsTestCase );
+ CPPUNIT_TEST( GetColour );
+ CPPUNIT_TEST( GetFont );
+ CPPUNIT_TEST( GlobalColours );
+ CPPUNIT_TEST( GlobalFonts );
+ CPPUNIT_TEST( GlobalBrushes );
+ CPPUNIT_TEST( GlobalPens );
+ CPPUNIT_TEST_SUITE_END();
+
+ void GetColour();
+ void GetFont();
+
+ // not really wxSystemSettings stuff but still nice to test:
+ void GlobalColours();
+ void GlobalFonts();
+ void GlobalBrushes();
+ void GlobalPens();
+
+ DECLARE_NO_COPY_CLASS(SettingsTestCase)
+};
+
+// register in the unnamed registry so that these tests are run by default
+CPPUNIT_TEST_SUITE_REGISTRATION( SettingsTestCase );
+
+// also include in it's own registry so that these tests can be run alone
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( SettingsTestCase, "SettingsTestCase" );
+
+
+void SettingsTestCase::GetColour()
+{
+ for (unsigned int i=wxSYS_COLOUR_SCROLLBAR; i < wxSYS_COLOUR_MAX; i++)
+ CPPUNIT_ASSERT( wxSystemSettings::GetColour((wxSystemColour)i).IsOk() );
+}
+
+void SettingsTestCase::GetFont()
+{
+ const wxSystemFont ids[] =
+ {
+ wxSYS_OEM_FIXED_FONT,
+ wxSYS_ANSI_FIXED_FONT,
+ wxSYS_ANSI_VAR_FONT,
+ wxSYS_SYSTEM_FONT,
+ wxSYS_DEVICE_DEFAULT_FONT,
+ wxSYS_SYSTEM_FIXED_FONT,
+ wxSYS_DEFAULT_GUI_FONT
+ };
+
+ for (unsigned int i=0; i < WXSIZEOF(ids); i++)
+ {
+ const wxFont& font = wxSystemSettings::GetFont(ids[i]);
+ CPPUNIT_ASSERT( font.IsOk() &&
+ wxFontEnumerator::IsValidFacename(font.GetFaceName()) );
+ }
+}
+
+void SettingsTestCase::GlobalColours()
+{
+ wxColour col[] =
+ {
+ *wxBLACK,
+ *wxBLUE,
+ *wxCYAN,
+ *wxGREEN,
+ *wxLIGHT_GREY,
+ *wxRED,
+ *wxWHITE
+ };
+
+ for (unsigned int i=0; i < WXSIZEOF(col); i++)
+ CPPUNIT_ASSERT( col[i].IsOk() );
+}
+
+void SettingsTestCase::GlobalFonts()
+{
+ wxFont font[] =
+ {
+ *wxNORMAL_FONT,
+ *wxSMALL_FONT,
+ *wxITALIC_FONT,
+ *wxSWISS_FONT
+ };
+
+ for (unsigned int i=0; i < WXSIZEOF(font); i++)
+ CPPUNIT_ASSERT( font[i].IsOk() &&
+ wxFontEnumerator::IsValidFacename(font[i].GetFaceName()) );
+}
+
+void SettingsTestCase::GlobalBrushes()
+{
+ wxBrush brush[] =
+ {
+ *wxBLACK_BRUSH,
+ *wxBLUE_BRUSH,
+ *wxCYAN_BRUSH,
+ *wxGREEN_BRUSH,
+ *wxGREY_BRUSH,
+ *wxLIGHT_GREY_BRUSH,
+ *wxMEDIUM_GREY_BRUSH,
+ *wxRED_BRUSH,
+ *wxTRANSPARENT_BRUSH,
+ *wxWHITE_BRUSH
+ };
+
+ for (unsigned int i=0; i < WXSIZEOF(brush); i++)
+ CPPUNIT_ASSERT( brush[i].IsOk() );
+}
+
+void SettingsTestCase::GlobalPens()
+{
+ wxPen pen[] =
+ {
+ *wxBLACK_DASHED_PEN,
+ *wxBLACK_PEN,
+ *wxBLUE_PEN,
+ *wxCYAN_PEN,
+ *wxGREEN_PEN,
+ *wxGREY_PEN,
+ *wxLIGHT_GREY_PEN,
+ *wxMEDIUM_GREY_PEN,
+ *wxRED_PEN,
+ *wxTRANSPARENT_PEN,
+ *wxWHITE_PEN
+ };
+
+ for (unsigned int i=0; i < WXSIZEOF(pen); i++)
+ CPPUNIT_ASSERT( pen[i].IsOk() );
+}
misc/guifuncs.cpp
misc/selstoretest.cpp
misc/garbage.cpp
+ misc/settings.cpp
<!--
This one is intentionally duplicated here (it is also part of
non-GUI test) as sockets behave differently in console and GUI
# End Source File\r
# Begin Source File\r
\r
+SOURCE=.\misc\settings.cpp\r
+# End Source File\r
+# Begin Source File\r
+\r
SOURCE=.\geometry\size.cpp\r
# End Source File\r
# Begin Source File\r
<File\r
RelativePath=".\window\setsize.cpp">\r
</File>\r
+ <File\r
+ RelativePath=".\misc\settings.cpp">\r
+ </File>\r
<File\r
RelativePath=".\geometry\size.cpp">\r
</File>\r
RelativePath=".\window\setsize.cpp"\r
>\r
</File>\r
+ <File\r
+ RelativePath=".\misc\settings.cpp"\r
+ >\r
+ </File>\r
<File\r
RelativePath=".\geometry\size.cpp"\r
>\r
RelativePath=".\window\setsize.cpp"\r
>\r
</File>\r
+ <File\r
+ RelativePath=".\misc\settings.cpp"\r
+ >\r
+ </File>\r
<File\r
RelativePath=".\geometry\size.cpp"\r
>\r