- Added wxVListBox::GetItemRect() (Javier Urien).
- Show busy cursor in wxLaunchDefaultBrowser and add wxBROWSER_NOBUSYCURSOR.
- Added wxFlexGridSizer::Is{Row,Col}Growable() (Marcin Wojdyr).
+- Added "enabled" and "hidden" attributes to radio box items in XRC.
wxGTK:
----------
This control may have "dimension" (major dimension) and (initial) "selection"
-Integer subelements and a composite "content" element similar to wxCheckList.
-The only difference is that the "item" subelements can have an optional
-"tooltip=I18nString" and "helptext=I18nString" attributes to specify
-the per-item tooltip and helptext.
+Integer subelements and a composite "content" element similar to wxCheckList
+except that <item> subelements can have additional attributes:
+
+tooltip I18nString ""
+helptext I18nString ""
+enabled Boolean 1
+hidden Boolean 0
wxScrolledWindow
bool m_insideBox;
// the items labels
- wxArrayString labels;
+ wxArrayString m_labels;
+#if wxUSE_TOOLTIPS
// the items tooltips
- wxArrayString tooltips;
+ wxArrayString m_tooltips;
+#endif // wxUSE_TOOLTIPS
// the item help text
- wxArrayString helptexts;
- wxArrayInt helptextSpecified;
+ wxArrayString m_helptexts;
+ wxArrayInt m_helptextSpecified;
+
+ // if the corresponding array element is 1, the radiobox item is
+ // disabled/hidden
+ wxArrayInt m_isEnabled,
+ m_isShown;
};
#endif // wxUSE_XRC && wxUSE_RADIOBOX
// Gets a font.
wxFont GetFont(const wxString& param = wxT("font"));
+ // Gets the value of a boolean attribute (only "0" and "1" are valid values)
+ bool GetBoolAttr(const wxString& attr, bool defaultv);
+
+
// Sets common window options.
void SetupWindow(wxWindow *wnd);
<selection>0</selection>
<content>
<item tooltip="Powerful radio station" helptext="This station is for amateurs of hard rock and heavy metal">Power 108</item>
+ <item tooltip="Disabled radio station" enabled="0">Power 0</item>
<item tooltip="">WMMS 100.7</item>
<item tooltip="E=mc^2">Energy 98.3</item>
<item helptext="Favourite chukcha's radio">CHUM FM</item>
<item>92FM</item>
+ <item hidden="1">Very quite station</item>
</content>
</object>
</object>
// directory operations
// ----------------------------------------------------------------------------
-wxString wxFileName::GetTempDir()
+// helper of GetTempDir(): check if the given directory exists and return it if
+// it does or an empty string otherwise
+namespace
{
- wxString dir;
- dir = wxGetenv(_T("TMPDIR"));
- if (dir.empty())
- {
- dir = wxGetenv(_T("TMP"));
- if (dir.empty())
- {
- dir = wxGetenv(_T("TEMP"));
- }
- }
-#if defined(__WXWINCE__)
- if (dir.empty())
+wxString CheckIfDirExists(const wxString& dir)
+{
+ return wxFileName::DirExists(dir) ? dir : wxString();
+}
+
+} // anonymous namespace
+
+wxString wxFileName::GetTempDir()
+{
+ // first try getting it from environment: this allows overriding the values
+ // used by default if the user wants to create temporary files in another
+ // directory
+ wxString dir = CheckIfDirExists(wxGetenv("TMPDIR"));
+ if ( dir.empty() )
{
- // FIXME. Create \temp dir?
- if (DirExists(wxT("\\temp")))
- dir = wxT("\\temp");
+ dir = CheckIfDirExists(wxGetenv("TMP"));
+ if ( dir.empty() )
+ dir = CheckIfDirExists(wxGetenv("TEMP"));
}
-#elif defined(__WINDOWS__) && !defined(__WXMICROWIN__)
+ // if no environment variables are set, use the system default
if ( dir.empty() )
{
+#if defined(__WXWINCE__)
+ dir = CheckIfDirExists(wxT("\\temp"));
+#elif defined(__WINDOWS__) && !defined(__WXMICROWIN__)
if ( !::GetTempPath(MAX_PATH, wxStringBuffer(dir, MAX_PATH + 1)) )
{
wxLogLastError(_T("GetTempPath"));
}
-
- if ( dir.empty() )
- {
- // GetTempFileName() fails if we pass it an empty string
- dir = _T('.');
- }
+#elif defined(__WXMAC__) && wxOSX_USE_CARBON
+ dir = wxMacFindFolder(short(kOnSystemDisk), kTemporaryFolderType, kCreateFolder);
+#endif // systems with native way
}
-#else // !Windows
+ // fall back to hard coded value
if ( dir.empty() )
{
- // default
-#if defined(__DOS__) || defined(__OS2__)
- dir = _T(".");
-#elif defined(__WXMAC__) && wxOSX_USE_CARBON
- dir = wxMacFindFolder(short(kOnSystemDisk), kTemporaryFolderType, kCreateFolder);
-#else
- dir = _T("/tmp");
-#endif
+#ifdef __UNIX_LIKE__
+ dir = CheckIfDirExists("/tmp");
+ if ( dir.empty() )
+#endif // __UNIX_LIKE__
+ dir = ".";
}
-#endif
return dir;
}
m_insideBox = true;
CreateChildrenPrivately( NULL, GetParamNode(wxT("content")));
- wxString *strings;
- if ( !labels.empty() )
- {
- strings = new wxString[labels.size()];
- const unsigned count = labels.size();
- for( unsigned i = 0; i < count; i++ )
- strings[i] = labels[i];
- }
- else
- {
- strings = NULL;
- }
-
XRC_MAKE_INSTANCE(control, wxRadioBox)
control->Create(m_parentAsWindow,
GetID(),
GetText(wxT("label")),
GetPosition(), GetSize(),
- labels.size(),
- strings,
+ m_labels,
GetLong(wxT("dimension"), 1),
GetStyle(),
wxDefaultValidator,
GetName());
- delete[] strings;
-
if (selection != -1)
control->SetSelection(selection);
SetupWindow(control);
- const unsigned count = labels.size();
+ const unsigned count = m_labels.size();
for( unsigned i = 0; i < count; i++ )
{
#if wxUSE_TOOLTIPS
- if ( !tooltips[i].empty() )
- control->SetItemToolTip(i, tooltips[i]);
+ if ( !m_tooltips[i].empty() )
+ control->SetItemToolTip(i, m_tooltips[i]);
#endif // wxUSE_TOOLTIPS
#if wxUSE_HELP
- if ( helptextSpecified[i] )
- control->SetItemHelpText(i, helptexts[i]);
+ if ( m_helptextSpecified[i] )
+ control->SetItemHelpText(i, m_helptexts[i]);
#endif // wxUSE_HELP
+
+ if ( !m_isShown[i] )
+ control->Show(i, false);
+ if ( !m_isEnabled[i] )
+ control->Enable(i, false);
}
- labels.clear(); // dump the strings
- tooltips.clear(); // dump the tooltips
+ // forget information about the items of this radiobox, we should start
+ // afresh for the next one
+ m_labels.clear();
- helptexts.clear(); // dump the helptexts
- helptextSpecified.clear();
+#if wxUSE_TOOLTIPS
+ m_tooltips.clear();
+#endif // wxUSE_TOOLTIPS
+
+#if wxUSE_HELP
+ m_helptexts.clear();
+ m_helptextSpecified.clear();
+#endif // wxUSE_HELP
+
+ m_isShown.clear();
+ m_isEnabled.clear();
return control;
}
else // inside the radiobox element
{
- // we handle handle <item tooltip="..." helptext="...">Label</item> constructs here
+ // we handle handle <item>Label</item> constructs here, and the item
+ // tag can have tooltip, helptext, enabled and hidden attributes
- wxString str = GetNodeContent(m_node);
+ wxString label = GetNodeContent(m_node);
wxString tooltip;
m_node->GetAttribute(wxT("tooltip"), &tooltip);
if (m_resource->GetFlags() & wxXRC_USE_LOCALE)
{
- str = wxGetTranslation(str, m_resource->GetDomain());
+ label = wxGetTranslation(label, m_resource->GetDomain());
if ( !tooltip.empty() )
tooltip = wxGetTranslation(tooltip, m_resource->GetDomain());
if ( hasHelptext )
helptext = wxGetTranslation(helptext, m_resource->GetDomain());
}
- labels.push_back(str);
- tooltips.push_back(tooltip);
- helptexts.push_back(helptext);
- helptextSpecified.push_back(hasHelptext);
+ m_labels.push_back(label);
+#if wxUSE_TOOLTIPS
+ m_tooltips.push_back(tooltip);
+#endif // wxUSE_TOOLTIPS
+#if wxUSE_HELP
+ m_helptexts.push_back(helptext);
+ m_helptextSpecified.push_back(hasHelptext);
+#endif // wxUSE_HELP
+ m_isEnabled.push_back(GetBoolAttr("enabled", 1));
+ m_isShown.push_back(!GetBoolAttr("hidden", 0));
return NULL;
}
+bool wxXmlResourceHandler::GetBoolAttr(const wxString& attr, bool defaultv)
+{
+ wxString v;
+ return m_node->GetAttribute(attr, &v) ? v == '1' : defaultv;
+}
+
bool wxXmlResourceHandler::GetBool(const wxString& param, bool defaultv)
{
- wxString v = GetParamValue(param);
- v.MakeLower();
- if (!v) return defaultv;
+ const wxString v = GetParamValue(param);
- return (v == wxT("1"));
+ return v.empty() ? defaultv : (v == '1');
}