// Get colour in HTML syntax (#RRGGBB)
wxColour GetColour(const wxString& param);
- // Get size/position:
+ // Get size/position (may be in dlg units):
wxSize GetSize(const wxString& param = _T("size"));
wxPoint GetPosition(const wxString& param = _T("pos"));
+
+ // Get dimension (may be in dlg units):
+ wxCoord GetDimension(const wxString& param, wxCoord defaultv = 0);
// Get bitmap:
wxBitmap GetBitmap(const wxString& param = _T("bitmap"), wxSize size = wxDefaultSize);
}
if( HasParam( _T("shadow") ))
{
- control->SetShadowWidth( GetLong( _T("shadow") ));
+ control->SetShadowWidth( GetDimension( _T("shadow") ));
}
if( HasParam( _T("bezel") ))
{
- control->SetBezelFace( GetLong( _T("bezel") ));
+ control->SetBezelFace( GetDimension( _T("bezel") ));
}
SetupWindow(control);
if( HasParam( _T("borders") ))
{
- control->SetBorders( GetLong( _T("borders" )));
+ control->SetBorders( GetDimension( _T("borders" )));
}
if( HasParam( _T("url") ))
if (sizer)
{
m_ParentSizer->Add(sizer, GetLong(_T("option")),
- GetStyle(_T("flag")), GetLong(_T("border")));
+ GetStyle(_T("flag")), GetDimension(_T("border")));
if (!(minsize == wxDefaultSize))
m_ParentSizer->SetItemMinSize(sizer, minsize.x, minsize.y);
}
else if (wnd)
{
m_ParentSizer->Add(wnd, GetLong(_T("option")),
- GetStyle(_T("flag")), GetLong(_T("border")));
+ GetStyle(_T("flag")), GetDimension(_T("border")));
if (!(minsize == wxDefaultSize))
m_ParentSizer->SetItemMinSize(wnd, minsize.x, minsize.y);
}
wxCHECK_MSG(m_ParentSizer, NULL, _T("Incorrect syntax of XML resource: spacer not within sizer!"));
wxSize sz = GetSize();
m_ParentSizer->Add(sz.x, sz.y,
- GetLong(_T("option")), GetStyle(_T("flag")), GetLong(_T("border")));
+ GetLong(_T("option")), GetStyle(_T("flag")), GetDimension(_T("border")));
return NULL;
}
else if (m_Node->GetName() == _T("gridsizer"))
sizer = new wxGridSizer(GetLong(_T("rows")), GetLong(_T("cols")),
- GetLong(_T("vgap")), GetLong(_T("hgap")));
+ GetDimension(_T("vgap")), GetDimension(_T("hgap")));
else if (m_Node->GetName() == _T("flexgridsizer"))
sizer = new wxFlexGridSizer(GetLong(_T("rows")), GetLong(_T("cols")),
- GetLong(_T("vgap")), GetLong(_T("hgap")));
+ GetDimension(_T("vgap")), GetDimension(_T("hgap")));
wxSize minsize = GetSize(_T("minsize"));
if (!(minsize == wxDefaultSize))
wxIcon wxXmlResourceHandler::GetIcon(const wxString& param, wxSize size)
{
-#ifdef __WXMSW__
+#if wxCHECK_VERSION(2,3,0) || defined(__WXMSW__)
wxIcon icon;
icon.CopyFromBitmap(GetBitmap(param, size));
#else
+wxCoord wxXmlResourceHandler::GetDimension(const wxString& param, wxCoord defaultv)
+{
+ wxString s = GetParamValue(param);
+ if (s.IsEmpty()) return defaultv;
+ bool is_dlg;
+ long sx;
+
+ is_dlg = s[s.Length()-1] == _T('d');
+ if (is_dlg) s.RemoveLast();
+
+ if (!s.ToLong(&sx))
+ {
+ wxLogError(_("Cannot parse dimension from '%s'."), s.mb_str());
+ return defaultv;
+ }
+
+ if (is_dlg)
+ {
+ if (m_InstanceAsWindow)
+ return wxDLG_UNIT(m_InstanceAsWindow, wxSize(sx, 0)).x;
+ else if (m_ParentAsWindow)
+ return wxDLG_UNIT(m_ParentAsWindow, wxSize(sx, 0)).x;
+ else
+ {
+ wxLogError(_("Cannot convert dialog units: dialog unknown."));
+ return defaultv;
+ }
+ }
+ else return sx;
+}
+
+
+
void wxXmlResourceHandler::SetupWindow(wxWindow *wnd)
{
//FIXME : add font, cursor
{
if (strcmp(rec->key, str_id) == 0)
{
-#ifdef DEBUG_XMLID_HASH
- printf("XMLID: matched '%s' (%ith item)\n", rec->key, matchcnt);
-#endif
return rec->id;
}
matchcnt++;
(*rec_var)->id = ++XMLID_LastID;
(*rec_var)->key = strdup(str_id);
(*rec_var)->next = NULL;
-#ifdef DEBUG_XMLID_HASH
- printf("XMLID: new key for '%s': %i at %i (%ith item)\n",
- (*rec_var)->key, (*rec_var)->id, index, matchcnt);
-#endif
return (*rec_var)->id;
}
{
if (rec)
{
-#ifdef DEBUG_XMLID_HASH
- printf("XMLID: clearing '%s'\n", rec->key);
-#endif
CleanXMLID_Record(rec->next);
free (rec->key);
delete rec;
derived from panel_item
var rows of integer
var cols of integer
-var vgap of integer
-var hgap of integer
+var vgap of dimension
+var hgap of dimension
var minsize of coord
var style of flags wxGA_HORIZONTAL,wxGA_VERTICAL,wxGA_PROGRESSBAR,wxGA_SMOOTH
var range of integer
var value of integer
-var shadow of integer
-var bezel of integer
+var shadow of dimension
+var bezel of dimension
derived from control
derived from panel_item
var rows of integer
var cols of integer
-var vgap of integer
-var hgap of integer
+var vgap of dimension
+var hgap of dimension
var minsize of coord
node htmlwindow
var url of text
var htmlcode of text
-var borders of integer
+var borders of dimension
var style of flags wxHW_SCROLLBAR_NEVER,wxHW_SCROLLBAR_AUTO
derived from control
var checkable of bool
var checked of bool
var enabled of bool
-derived from menu_item
\ No newline at end of file
+derived from menu_item
--- /dev/null
+node radiobox
+var style of flags wxRA_SPECIFY_COLS,wxRA_HORIZONTAL,wxRA_SPECIFY_ROWS,wxRA_VERTICAL
+var label of text
+var dimension of integer
+var selection of integer
+var content of not_implemented
+derived from control
type sizeritem
var option of integer
var flag of flags wxEXPAND,wxALL,wxLEFT,wxRIGHT,wxTOP,wxBOTTOM,wxALIGN_CENTER,wxALIGN_LEFT,wxALIGN_TOP,wxALIGN_RIGHT,wxALIGN_BOTTOM,wxALIGN_CENTER_HORIZONTAL,wxALIGN_CENTER_VERTICAL,wxNORTH,wxSOUTH,wxEAST,wxWEST,wxGROW,wxSHAPED,wxSTRETCH_NOT
-var border of integer
+var border of dimension
var minsize of coord
type normal
var option of integer
var flag of flags wxEXPAND,wxALL,wxLEFT,wxRIGHT,wxTOP,wxBOTTOM,wxALIGN_CENTER,wxALIGN_LEFT,wxALIGN_TOP,wxALIGN_RIGHT,wxALIGN_BOTTOM,wxALIGN_CENTER_HORIZONTAL,wxALIGN_CENTER_VERTICAL,wxNORTH,wxSOUTH,wxEAST,wxWEST,wxGROW,wxSHAPED,wxSTRETCH_NOT
-var border of integer
+var border of dimension
var size of coord
derived from sizer_item
tkn.GetNextToken();
wxString typ = tkn.GetNextToken();
if (tkn.HasMoreTokens()) pi.MoreInfo = tkn.GetNextToken();
+ /* ADD NEW PROPERTY TYPES HERE
+ (search for other occurences of this comment in _all_ files) */
if (typ == "color") pi.Type = PROP_COLOR;
else if (typ == "flags") pi.Type = PROP_FLAGS;
else if (typ == "bool") pi.Type = PROP_BOOL;
else if (typ == "integer") pi.Type = PROP_INTEGER;
else if (typ == "coord") pi.Type = PROP_COORD;
+ else if (typ == "dimension") pi.Type = PROP_DIMENSION;
else if (typ == "not_implemented") pi.Type = PROP_NOT_IMPLEMENTED;
else /*if (typ == "text")*/ pi.Type = PROP_TEXT;
void NodeHandler::CreatePropHandlers()
{
+ /* ADD NEW PROPERTY TYPES HERE
+ (search for other occurences of this comment in _all_ files) */
s_PropHandlers[PROP_TEXT] = new TextPropertyHandler;
s_PropHandlers[PROP_FLAGS] = new FlagsPropertyHandler;
s_PropHandlers[PROP_COLOR] = new TextPropertyHandler;
s_PropHandlers[PROP_BOOL] = new BoolPropertyHandler;
s_PropHandlers[PROP_INTEGER] = new TextPropertyHandler;
s_PropHandlers[PROP_COORD] = new CoordPropertyHandler;
+ s_PropHandlers[PROP_DIMENSION] = new DimensionPropertyHandler;
s_PropHandlers[PROP_NOT_IMPLEMENTED] = new NotImplPropertyHandler;
}
+class DimensionPropPanel : public PropertyPanel
+{
+ public:
+ DimensionPropPanel(wxWindow *parent, PropertyHandler *hnd, PropsListInfo *pli) : PropertyPanel(parent, hnd, pli)
+ {
+ wxSizer *sizer = new wxBoxSizer(wxVERTICAL);
+ m_ed1 = NULL; m_chb = NULL;
+
+ sizer->Add(new wxStaticText(this, -1, _("Value:")), 0, wxLEFT, 5);
+ sizer->Add(m_ed1 = new wxTextCtrl(this, ID_XEDIT, "",
+ wxDefaultPosition, wxDefaultSize, 0,
+ wxTextValidator(wxFILTER_NUMERIC)),
+ 0, wxEXPAND, 5);
+ m_ed1->SetFocus();
+
+ sizer->Add(m_chb = new wxCheckBox(this, ID_USEDLG, _("Use dialog units")), 0, wxLEFT|wxTOP, 5);
+
+ SetAutoLayout(TRUE);
+ SetSizer(sizer);
+ Layout();
+
+ wxString val = XmlReadValue(pli->m_Node, pli->m_PropInfo->Name);
+ m_chb->SetValue(val.Len()>0 && val[val.Len()-1] == 'd');
+ m_ed1->SetValue(val.BeforeFirst('d'));
+ }
+
+ void OnEdit(wxCommandEvent &event)
+ {
+ wxString val;
+
+ if (m_ed1 == NULL || m_chb == NULL) return;
+
+ val = m_ed1->GetValue();
+ if (val.IsEmpty()) return;
+ if (m_chb->GetValue()) val << 'd';
+ Update(val);
+ }
+
+ wxTextCtrl *m_ed1;
+ wxCheckBox *m_chb;
+
+ DECLARE_EVENT_TABLE()
+};
+
+BEGIN_EVENT_TABLE(DimensionPropPanel, PropertyPanel)
+ EVT_TEXT(ID_XEDIT, DimensionPropPanel::OnEdit)
+ EVT_TEXT(ID_YEDIT, DimensionPropPanel::OnEdit)
+ EVT_CHECKBOX(ID_USEDLG, DimensionPropPanel::OnEdit)
+END_EVENT_TABLE()
+
+wxPanel *DimensionPropertyHandler::CreateEditPanel(wxWindow *parent, PropsListInfo *pli)
+{
+ return new DimensionPropPanel(parent, this, pli);
+}
+
+
+
+
+
+
class BoolPropPanel : public PropertyPanel
{
#include "wx/xml/xml.h"
#include "wx/dynarray.h"
+/* ADD NEW PROPERTY TYPES HERE
+ (search for other occurences of this comment in _all_ files) */
enum PropertyType
{
PROP_TEXT = 0,
PROP_BOOL = 3,
PROP_INTEGER = 4,
PROP_COORD = 5,
- PROP_NOT_IMPLEMENTED = 6,
+ PROP_DIMENSION = 6,
+ PROP_NOT_IMPLEMENTED = 7,
};
-#define PROP_TYPES_CNT 7
+#define PROP_TYPES_CNT 8
class PropertyInfo
{
};
+class DimensionPropertyHandler : public PropertyHandler
+{
+ public:
+ DimensionPropertyHandler() {}
+ virtual wxPanel *CreateEditPanel(wxWindow *parent, PropsListInfo *pli);
+};
+
+
class BoolPropertyHandler : public PropertyHandler
{
public: