added enabled and hidden attributes to radio box items in XRC
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@54929 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -377,6 +377,7 @@ All (GUI):
|
|||||||
- Added wxVListBox::GetItemRect() (Javier Urien).
|
- Added wxVListBox::GetItemRect() (Javier Urien).
|
||||||
- Show busy cursor in wxLaunchDefaultBrowser and add wxBROWSER_NOBUSYCURSOR.
|
- Show busy cursor in wxLaunchDefaultBrowser and add wxBROWSER_NOBUSYCURSOR.
|
||||||
- Added wxFlexGridSizer::Is{Row,Col}Growable() (Marcin Wojdyr).
|
- Added wxFlexGridSizer::Is{Row,Col}Growable() (Marcin Wojdyr).
|
||||||
|
- Added "enabled" and "hidden" attributes to radio box items in XRC.
|
||||||
|
|
||||||
wxGTK:
|
wxGTK:
|
||||||
|
|
||||||
|
@@ -421,10 +421,13 @@ wxRadioBox
|
|||||||
----------
|
----------
|
||||||
|
|
||||||
This control may have "dimension" (major dimension) and (initial) "selection"
|
This control may have "dimension" (major dimension) and (initial) "selection"
|
||||||
Integer subelements and a composite "content" element similar to wxCheckList.
|
Integer subelements and a composite "content" element similar to wxCheckList
|
||||||
The only difference is that the "item" subelements can have an optional
|
except that <item> subelements can have additional attributes:
|
||||||
"tooltip=I18nString" and "helptext=I18nString" attributes to specify
|
|
||||||
the per-item tooltip and helptext.
|
tooltip I18nString ""
|
||||||
|
helptext I18nString ""
|
||||||
|
enabled Boolean 1
|
||||||
|
hidden Boolean 0
|
||||||
|
|
||||||
|
|
||||||
wxScrolledWindow
|
wxScrolledWindow
|
||||||
|
@@ -28,14 +28,21 @@ private:
|
|||||||
bool m_insideBox;
|
bool m_insideBox;
|
||||||
|
|
||||||
// the items labels
|
// the items labels
|
||||||
wxArrayString labels;
|
wxArrayString m_labels;
|
||||||
|
|
||||||
|
#if wxUSE_TOOLTIPS
|
||||||
// the items tooltips
|
// the items tooltips
|
||||||
wxArrayString tooltips;
|
wxArrayString m_tooltips;
|
||||||
|
#endif // wxUSE_TOOLTIPS
|
||||||
|
|
||||||
// the item help text
|
// the item help text
|
||||||
wxArrayString helptexts;
|
wxArrayString m_helptexts;
|
||||||
wxArrayInt helptextSpecified;
|
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
|
#endif // wxUSE_XRC && wxUSE_RADIOBOX
|
||||||
|
@@ -462,6 +462,10 @@ protected:
|
|||||||
// Gets a font.
|
// Gets a font.
|
||||||
wxFont GetFont(const wxString& param = wxT("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.
|
// Sets common window options.
|
||||||
void SetupWindow(wxWindow *wnd);
|
void SetupWindow(wxWindow *wnd);
|
||||||
|
|
||||||
|
@@ -704,10 +704,12 @@
|
|||||||
<selection>0</selection>
|
<selection>0</selection>
|
||||||
<content>
|
<content>
|
||||||
<item tooltip="Powerful radio station" helptext="This station is for amateurs of hard rock and heavy metal">Power 108</item>
|
<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="">WMMS 100.7</item>
|
||||||
<item tooltip="E=mc^2">Energy 98.3</item>
|
<item tooltip="E=mc^2">Energy 98.3</item>
|
||||||
<item helptext="Favourite chukcha's radio">CHUM FM</item>
|
<item helptext="Favourite chukcha's radio">CHUM FM</item>
|
||||||
<item>92FM</item>
|
<item>92FM</item>
|
||||||
|
<item hidden="1">Very quite station</item>
|
||||||
</content>
|
</content>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
|
@@ -1026,55 +1026,55 @@ wxFileName::CreateTempFileName(const wxString& prefix, wxFFile *fileTemp)
|
|||||||
// directory operations
|
// directory operations
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// helper of GetTempDir(): check if the given directory exists and return it if
|
||||||
|
// it does or an empty string otherwise
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
|
wxString CheckIfDirExists(const wxString& dir)
|
||||||
|
{
|
||||||
|
return wxFileName::DirExists(dir) ? dir : wxString();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // anonymous namespace
|
||||||
|
|
||||||
wxString wxFileName::GetTempDir()
|
wxString wxFileName::GetTempDir()
|
||||||
{
|
{
|
||||||
wxString dir;
|
// first try getting it from environment: this allows overriding the values
|
||||||
dir = wxGetenv(_T("TMPDIR"));
|
// used by default if the user wants to create temporary files in another
|
||||||
|
// directory
|
||||||
|
wxString dir = CheckIfDirExists(wxGetenv("TMPDIR"));
|
||||||
if ( dir.empty() )
|
if ( dir.empty() )
|
||||||
{
|
{
|
||||||
dir = wxGetenv(_T("TMP"));
|
dir = CheckIfDirExists(wxGetenv("TMP"));
|
||||||
if ( dir.empty() )
|
if ( dir.empty() )
|
||||||
{
|
dir = CheckIfDirExists(wxGetenv("TEMP"));
|
||||||
dir = wxGetenv(_T("TEMP"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if no environment variables are set, use the system default
|
||||||
|
if ( dir.empty() )
|
||||||
|
{
|
||||||
#if defined(__WXWINCE__)
|
#if defined(__WXWINCE__)
|
||||||
if (dir.empty())
|
dir = CheckIfDirExists(wxT("\\temp"));
|
||||||
{
|
|
||||||
// FIXME. Create \temp dir?
|
|
||||||
if (DirExists(wxT("\\temp")))
|
|
||||||
dir = wxT("\\temp");
|
|
||||||
}
|
|
||||||
#elif defined(__WINDOWS__) && !defined(__WXMICROWIN__)
|
#elif defined(__WINDOWS__) && !defined(__WXMICROWIN__)
|
||||||
|
|
||||||
if ( dir.empty() )
|
|
||||||
{
|
|
||||||
if ( !::GetTempPath(MAX_PATH, wxStringBuffer(dir, MAX_PATH + 1)) )
|
if ( !::GetTempPath(MAX_PATH, wxStringBuffer(dir, MAX_PATH + 1)) )
|
||||||
{
|
{
|
||||||
wxLogLastError(_T("GetTempPath"));
|
wxLogLastError(_T("GetTempPath"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( dir.empty() )
|
|
||||||
{
|
|
||||||
// GetTempFileName() fails if we pass it an empty string
|
|
||||||
dir = _T('.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#else // !Windows
|
|
||||||
|
|
||||||
if ( dir.empty() )
|
|
||||||
{
|
|
||||||
// default
|
|
||||||
#if defined(__DOS__) || defined(__OS2__)
|
|
||||||
dir = _T(".");
|
|
||||||
#elif defined(__WXMAC__) && wxOSX_USE_CARBON
|
#elif defined(__WXMAC__) && wxOSX_USE_CARBON
|
||||||
dir = wxMacFindFolder(short(kOnSystemDisk), kTemporaryFolderType, kCreateFolder);
|
dir = wxMacFindFolder(short(kOnSystemDisk), kTemporaryFolderType, kCreateFolder);
|
||||||
#else
|
#endif // systems with native way
|
||||||
dir = _T("/tmp");
|
}
|
||||||
#endif
|
|
||||||
|
// fall back to hard coded value
|
||||||
|
if ( dir.empty() )
|
||||||
|
{
|
||||||
|
#ifdef __UNIX_LIKE__
|
||||||
|
dir = CheckIfDirExists("/tmp");
|
||||||
|
if ( dir.empty() )
|
||||||
|
#endif // __UNIX_LIKE__
|
||||||
|
dir = ".";
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
|
@@ -47,66 +47,66 @@ wxObject *wxRadioBoxXmlHandler::DoCreateResource()
|
|||||||
m_insideBox = true;
|
m_insideBox = true;
|
||||||
CreateChildrenPrivately( NULL, GetParamNode(wxT("content")));
|
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)
|
XRC_MAKE_INSTANCE(control, wxRadioBox)
|
||||||
|
|
||||||
control->Create(m_parentAsWindow,
|
control->Create(m_parentAsWindow,
|
||||||
GetID(),
|
GetID(),
|
||||||
GetText(wxT("label")),
|
GetText(wxT("label")),
|
||||||
GetPosition(), GetSize(),
|
GetPosition(), GetSize(),
|
||||||
labels.size(),
|
m_labels,
|
||||||
strings,
|
|
||||||
GetLong(wxT("dimension"), 1),
|
GetLong(wxT("dimension"), 1),
|
||||||
GetStyle(),
|
GetStyle(),
|
||||||
wxDefaultValidator,
|
wxDefaultValidator,
|
||||||
GetName());
|
GetName());
|
||||||
|
|
||||||
delete[] strings;
|
|
||||||
|
|
||||||
if (selection != -1)
|
if (selection != -1)
|
||||||
control->SetSelection(selection);
|
control->SetSelection(selection);
|
||||||
|
|
||||||
SetupWindow(control);
|
SetupWindow(control);
|
||||||
|
|
||||||
const unsigned count = labels.size();
|
const unsigned count = m_labels.size();
|
||||||
for( unsigned i = 0; i < count; i++ )
|
for( unsigned i = 0; i < count; i++ )
|
||||||
{
|
{
|
||||||
#if wxUSE_TOOLTIPS
|
#if wxUSE_TOOLTIPS
|
||||||
if ( !tooltips[i].empty() )
|
if ( !m_tooltips[i].empty() )
|
||||||
control->SetItemToolTip(i, tooltips[i]);
|
control->SetItemToolTip(i, m_tooltips[i]);
|
||||||
#endif // wxUSE_TOOLTIPS
|
#endif // wxUSE_TOOLTIPS
|
||||||
#if wxUSE_HELP
|
#if wxUSE_HELP
|
||||||
if ( helptextSpecified[i] )
|
if ( m_helptextSpecified[i] )
|
||||||
control->SetItemHelpText(i, helptexts[i]);
|
control->SetItemHelpText(i, m_helptexts[i]);
|
||||||
#endif // wxUSE_HELP
|
#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
|
#if wxUSE_TOOLTIPS
|
||||||
helptextSpecified.clear();
|
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;
|
return control;
|
||||||
}
|
}
|
||||||
else // inside the radiobox element
|
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;
|
wxString tooltip;
|
||||||
m_node->GetAttribute(wxT("tooltip"), &tooltip);
|
m_node->GetAttribute(wxT("tooltip"), &tooltip);
|
||||||
@@ -116,17 +116,23 @@ wxObject *wxRadioBoxXmlHandler::DoCreateResource()
|
|||||||
|
|
||||||
if (m_resource->GetFlags() & wxXRC_USE_LOCALE)
|
if (m_resource->GetFlags() & wxXRC_USE_LOCALE)
|
||||||
{
|
{
|
||||||
str = wxGetTranslation(str, m_resource->GetDomain());
|
label = wxGetTranslation(label, m_resource->GetDomain());
|
||||||
if ( !tooltip.empty() )
|
if ( !tooltip.empty() )
|
||||||
tooltip = wxGetTranslation(tooltip, m_resource->GetDomain());
|
tooltip = wxGetTranslation(tooltip, m_resource->GetDomain());
|
||||||
if ( hasHelptext )
|
if ( hasHelptext )
|
||||||
helptext = wxGetTranslation(helptext, m_resource->GetDomain());
|
helptext = wxGetTranslation(helptext, m_resource->GetDomain());
|
||||||
}
|
}
|
||||||
|
|
||||||
labels.push_back(str);
|
m_labels.push_back(label);
|
||||||
tooltips.push_back(tooltip);
|
#if wxUSE_TOOLTIPS
|
||||||
helptexts.push_back(helptext);
|
m_tooltips.push_back(tooltip);
|
||||||
helptextSpecified.push_back(hasHelptext);
|
#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;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@@ -1031,13 +1031,17 @@ wxString wxXmlResourceHandler::GetName()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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)
|
bool wxXmlResourceHandler::GetBool(const wxString& param, bool defaultv)
|
||||||
{
|
{
|
||||||
wxString v = GetParamValue(param);
|
const wxString v = GetParamValue(param);
|
||||||
v.MakeLower();
|
|
||||||
if (!v) return defaultv;
|
|
||||||
|
|
||||||
return (v == wxT("1"));
|
return v.empty() ? defaultv : (v == '1');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user