* wxDialogEditorPropertyListDialog
*/
+ /*
wxDialogEditorPropertyListDialog::wxDialogEditorPropertyListDialog(wxPropertyListView *v, wxWindow *parent, const wxString& title,
const wxPoint& pos, const wxSize& size,
long style, const wxString& name):
delete m_propInfo;
wxPropertyInfo::sm_propertyWindow = NULL;
}
+*/
+
+wxDialogEditorPropertyListFrame::wxDialogEditorPropertyListFrame(wxPropertyListView *v, wxFrame *parent, const wxString& title,
+ const wxPoint& pos, const wxSize& size,
+ long style, const wxString& name):
+ wxPropertyListFrame(v, parent, title, pos, size, style, name)
+{
+ m_propSheet = NULL;
+ m_propInfo = NULL;
+}
+
+wxDialogEditorPropertyListFrame::~wxDialogEditorPropertyListFrame()
+{
+ delete m_propSheet;
+ delete m_propInfo;
+ wxPropertyInfo::sm_propertyWindow = NULL;
+}
/*
* wxPropertyInfo
propSheet->SetAllModified(FALSE);
wxResourcePropertyListView *view = new wxResourcePropertyListView(this, NULL,
-#ifdef __XVIEW__
wxPROP_BUTTON_OK | wxPROP_BUTTON_CANCEL |
-#endif
wxPROP_BUTTON_CHECK_CROSS|wxPROP_DYNAMIC_VALUE_FIELD|wxPROP_PULLDOWN|wxPROP_SHOWVALUES);
- wxDialogEditorPropertyListDialog *propDialog = new wxDialogEditorPropertyListDialog(view,
+ wxDialogEditorPropertyListFrame *propWin = new wxDialogEditorPropertyListFrame(view,
wxResourceManager::GetCurrentResourceManager()->GetEditorFrame(), title, wxPoint(x, y),
- wxSize(width, height), wxDEFAULT_DIALOG_STYLE);
- sm_propertyWindow = propDialog;
+ wxSize(width, height), wxDEFAULT_FRAME_STYLE);
+ sm_propertyWindow = propWin;
- propDialog->m_registry.RegisterValidator((wxString)"real", new wxRealListValidator);
- propDialog->m_registry.RegisterValidator((wxString)"string", new wxStringListValidator);
- propDialog->m_registry.RegisterValidator((wxString)"integer", new wxIntegerListValidator);
- propDialog->m_registry.RegisterValidator((wxString)"bool", new wxBoolListValidator);
- propDialog->m_registry.RegisterValidator((wxString)"filename", new wxFilenameListValidator);
- propDialog->m_registry.RegisterValidator((wxString)"stringlist", new wxListOfStringsListValidator);
- propDialog->m_registry.RegisterValidator((wxString)"window_id", new wxResourceSymbolValidator);
+ propWin->m_registry.RegisterValidator((wxString)"real", new wxRealListValidator);
+ propWin->m_registry.RegisterValidator((wxString)"string", new wxStringListValidator);
+ propWin->m_registry.RegisterValidator((wxString)"integer", new wxIntegerListValidator);
+ propWin->m_registry.RegisterValidator((wxString)"bool", new wxBoolListValidator);
+ propWin->m_registry.RegisterValidator((wxString)"filename", new wxFilenameListValidator);
+ propWin->m_registry.RegisterValidator((wxString)"stringlist", new wxListOfStringsListValidator);
+ propWin->m_registry.RegisterValidator((wxString)"window_id", new wxResourceSymbolValidator);
- propDialog->m_propInfo = this;
- propDialog->m_propSheet = propSheet;
+ propWin->m_propInfo = this;
+ propWin->m_propSheet = propSheet;
-// view->propertyWindow = propDialog;
- view->AddRegistry(&(propDialog->m_registry));
- view->ShowView(propSheet, propDialog);
+// view->propertyWindow = propWin;
+ view->AddRegistry(&(propWin->m_registry));
- propDialog->Show(TRUE);
+ propWin->Initialize();
+ view->ShowView(propSheet, propWin->GetPropertyPanel());
+
+ propWin->Show(TRUE);
return TRUE;
}
}
else if (name == "id")
{
- wxString symbolName("TODO");
- return new wxProperty("id", symbolName, "window_id");
+ wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(propertyWindow);
+ if (resource)
+ {
+ int id = resource->GetId();
+ wxString idStr;
+ idStr.Printf("%d", id);
+ wxString symbolName = wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetSymbolForId(id);
+ symbolName += "=";
+ symbolName += idStr;
+ // symbolName is now e.g. "ID_PANEL21=105"
+ return new wxProperty("id", symbolName, "window_id");
+ }
+ else
+ return NULL;
}
else
return NULL;
}
else if (name == "id")
{
- // TODO
- return TRUE;
+ wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(propertyWindow);
+ if (resource)
+ {
+ wxString value = property->GetValue().StringValue();
+
+ wxString strName = value.Before('=');
+ wxString strId = value.After('=');
+ int id = atoi(strId);
+
+ wxString oldSymbolName = wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetSymbolForId(resource->GetId());
+ int oldSymbolId = resource->GetId();
+
+ if (strName != "")
+ {
+ // If we change the id for an existing symbol, we need to:
+ // 1) Check if there are any other resources currently using the original id.
+ // If so, will need to change their id to the new id.
+ // 2) Remove the old symbol, add the new symbol.
+ // In this check, we don't have to do this, but we need to do it in SetProperty.
+
+ if (strName == oldSymbolName && id != oldSymbolId)
+ {
+ wxASSERT( (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(oldSymbolName)) );
+
+ // It's OK to change just the id. But we'll need to change all matching ids in all resources,
+ // because ids are unique and changing one resource's id must change all identical ones.
+ wxResourceManager::GetCurrentResourceManager()->ChangeIds(oldSymbolId, id);
+
+ wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().RemoveSymbol(oldSymbolName);
+ wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().AddSymbol(strName, id);
+ }
+
+ // If we change the name but not the id, we'll just need to remove and
+ // re-add the symbol/id pair.
+ if (strName != oldSymbolName && id == oldSymbolId)
+ {
+ wxASSERT( (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(oldSymbolName)) );
+
+ wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().RemoveSymbol(oldSymbolName);
+
+ if (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().SymbolExists(strName))
+ {
+ wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().AddSymbol(strName, id);
+ }
+ }
+
+ // What if we're changing both the name and the id?
+ // - if there's no symbol of that name, just remove the old, add the new (in SetProperty)
+ // - if there is a symbol of that name, if id matches, do nothing. If not, veto.
+
+ if (strName != oldSymbolName && id != oldSymbolId)
+ {
+ // Remove old symbol if it's not being used
+ if (!wxResourceManager::GetCurrentResourceManager()->IsSymbolUsed(resource, oldSymbolId) &&
+ !wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(oldSymbolName))
+ {
+ wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().RemoveSymbol(oldSymbolName);
+ }
+
+ if (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().SymbolExists(strName))
+ {
+ wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().AddSymbol(strName, id);
+ }
+ }
+ resource->SetId(id);
+ }
+
+ return TRUE;
+ }
+ else
+ return FALSE;
}
else
return FALSE;
// Fill in the wxItemResource members to mirror the current window settings
bool wxWindowPropertyInfo::InstantiateResource(wxItemResource *resource)
{
- resource->SetType(propertyWindow->GetClassInfo()->GetClassName());
+// resource->SetType(propertyWindow->GetClassInfo()->GetClassName());
// resource->SetStyle(propertyWindow->GetWindowStyleFlag());
wxString str(propertyWindow->GetName());
return TRUE;
}
+// Set the window style
+void wxWindowPropertyInfo::SetWindowStyle(wxWindow* win, long style, bool set)
+{
+ if (style == 0)
+ return;
+
+ if ((win->GetWindowStyleFlag() & style) == style)
+ {
+ if (!set)
+ {
+ win->SetWindowStyleFlag(win->GetWindowStyleFlag() - style);
+ }
+ }
+ else
+ {
+ if (set)
+ {
+ win->SetWindowStyleFlag(win->GetWindowStyleFlag() | style);
+ }
+ }
+}
/*
* Controls
void wxButtonPropertyInfo::GetPropertyNames(wxStringList& names)
{
- names.Add("label");
wxItemPropertyInfo::GetPropertyNames(names);
+ names.Add("label");
}
bool wxButtonPropertyInfo::InstantiateResource(wxItemResource *resource)
void wxStaticTextPropertyInfo::GetPropertyNames(wxStringList& names)
{
- names.Add("label");
wxItemPropertyInfo::GetPropertyNames(names);
+ names.Add("label");
}
bool wxStaticTextPropertyInfo::InstantiateResource(wxItemResource *resource)
void wxStaticBitmapPropertyInfo::GetPropertyNames(wxStringList& names)
{
- names.Add("label");
wxItemPropertyInfo::GetPropertyNames(names);
+ names.Add("label");
}
bool wxStaticBitmapPropertyInfo::InstantiateResource(wxItemResource *resource)
void wxTextPropertyInfo::GetPropertyNames(wxStringList& names)
{
+ wxItemPropertyInfo::GetPropertyNames(names);
names.Add("value");
names.Add("readonly");
names.Add("password");
- wxItemPropertyInfo::GetPropertyNames(names);
}
bool wxTextPropertyInfo::InstantiateResource(wxItemResource *resource)
void wxListBoxPropertyInfo::GetPropertyNames(wxStringList& names)
{
+ wxItemPropertyInfo::GetPropertyNames(names);
names.Add("values");
names.Add("multiple");
- wxItemPropertyInfo::GetPropertyNames(names);
}
bool wxListBoxPropertyInfo::InstantiateResource(wxItemResource *resource)
void wxChoicePropertyInfo::GetPropertyNames(wxStringList& names)
{
- names.Add("values");
wxItemPropertyInfo::GetPropertyNames(names);
+ names.Add("values");
}
bool wxChoicePropertyInfo::InstantiateResource(wxItemResource *resource)
return wxItemPropertyInfo::InstantiateResource(resource);
}
+/*
+ * Choice item
+ */
+
+wxProperty *wxComboBoxPropertyInfo::GetProperty(wxString& name)
+{
+ wxComboBox *choice = (wxComboBox *)propertyWindow;
+ if (name == "values")
+ {
+ wxStringList *stringList = new wxStringList;
+ int i;
+ for (i = 0; i < choice->Number(); i++)
+ stringList->Add(choice->GetString(i));
+
+ return new wxProperty(name, stringList, "stringlist");
+ }
+ else if (name == "sort")
+ {
+ bool sort = ((propertyWindow->GetWindowStyleFlag() & wxCB_SORT) == wxCB_SORT);
+ return new wxProperty(name, sort, "bool");
+ }
+ else if (name == "style")
+ {
+ wxString styleStr("dropdown");
+ if (propertyWindow->GetWindowStyleFlag() & wxCB_SIMPLE)
+ styleStr = "simple";
+ else if (propertyWindow->GetWindowStyleFlag() & wxCB_READONLY)
+ styleStr = "readonly";
+ else
+ styleStr = "dropdown";
+
+ return new wxProperty(name, styleStr, "string",
+ new wxStringListValidator(new wxStringList("simple", "dropdown", "readonly",
+ NULL)));
+ }
+ else
+ return wxItemPropertyInfo::GetProperty(name);
+}
+
+bool wxComboBoxPropertyInfo::SetProperty(wxString& name, wxProperty *property)
+{
+ wxComboBox *choice = (wxComboBox *)propertyWindow;
+ if (name == "values")
+ {
+ choice->Clear();
+ wxPropertyValue *expr = property->GetValue().GetFirst();
+ while (expr)
+ {
+ char *s = expr->StringValue();
+ if (s)
+ choice->Append(s);
+ expr = expr->GetNext();
+ }
+ if (choice->Number() > 0)
+ choice->SetSelection(0);
+ return TRUE;
+ }
+ else if (name == "sort")
+ {
+ SetWindowStyle(propertyWindow, wxCB_SORT, property->GetValue().BoolValue());
+
+ wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(propertyWindow);
+ resource->SetStyle(propertyWindow->GetWindowStyleFlag());
+
+ wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(propertyWindow, this);
+ return TRUE;
+ }
+ else if (name == "style")
+ {
+ SetWindowStyle(propertyWindow, wxCB_SIMPLE, FALSE);
+ SetWindowStyle(propertyWindow, wxCB_DROPDOWN, FALSE);
+ SetWindowStyle(propertyWindow, wxCB_READONLY, FALSE);
+
+ wxString styleStr(property->GetValue().StringValue());
+ if (styleStr == "simple")
+ SetWindowStyle(propertyWindow, wxCB_SIMPLE, TRUE);
+ else if (styleStr == "dropdown")
+ SetWindowStyle(propertyWindow, wxCB_DROPDOWN, TRUE);
+ else if (styleStr == "readonly")
+ SetWindowStyle(propertyWindow, wxCB_READONLY, TRUE);
+
+ // Necesary?
+ wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(propertyWindow);
+ resource->SetStyle(propertyWindow->GetWindowStyleFlag());
+
+ wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(propertyWindow, this);
+
+ return TRUE;
+ }
+ else
+ return wxItemPropertyInfo::SetProperty(name, property);
+}
+
+void wxComboBoxPropertyInfo::GetPropertyNames(wxStringList& names)
+{
+ wxItemPropertyInfo::GetPropertyNames(names);
+ names.Add("values");
+ names.Add("style");
+ names.Add("sort");
+}
+
+bool wxComboBoxPropertyInfo::InstantiateResource(wxItemResource *resource)
+{
+ wxComboBox *choice = (wxComboBox *)propertyWindow;
+ int i;
+ if (choice->Number() == 0)
+ resource->SetStringValues(NULL);
+ else
+ {
+ wxStringList *slist = new wxStringList;
+
+ for (i = 0; i < choice->Number(); i++)
+ slist->Add(choice->GetString(i));
+
+ resource->SetStringValues(slist);
+ }
+ return wxItemPropertyInfo::InstantiateResource(resource);
+}
+
/*
* Radiobox item
*/
void wxRadioBoxPropertyInfo::GetPropertyNames(wxStringList& names)
{
+ wxItemPropertyInfo::GetPropertyNames(names);
names.Add("label");
names.Add("values");
names.Add("orientation");
names.Add("numberRowsOrCols");
- wxItemPropertyInfo::GetPropertyNames(names);
}
bool wxRadioBoxPropertyInfo::InstantiateResource(wxItemResource *resource)
void wxGroupBoxPropertyInfo::GetPropertyNames(wxStringList& names)
{
- names.Add("label");
wxItemPropertyInfo::GetPropertyNames(names);
+ names.Add("label");
}
bool wxGroupBoxPropertyInfo::InstantiateResource(wxItemResource *resource)
void wxCheckBoxPropertyInfo::GetPropertyNames(wxStringList& names)
{
+ wxItemPropertyInfo::GetPropertyNames(names);
names.Add("label");
names.Add("value");
- wxItemPropertyInfo::GetPropertyNames(names);
}
bool wxCheckBoxPropertyInfo::InstantiateResource(wxItemResource *resource)
void wxRadioButtonPropertyInfo::GetPropertyNames(wxStringList& names)
{
+ wxItemPropertyInfo::GetPropertyNames(names);
names.Add("label");
names.Add("value");
- wxItemPropertyInfo::GetPropertyNames(names);
}
bool wxRadioButtonPropertyInfo::InstantiateResource(wxItemResource *resource)
new wxStringListValidator(new wxStringList("wxHORIZONTAL", "wxVERTICAL",
NULL)));
}
- else if (name == "min_value")
- return new wxProperty("min_value", (long)slider->GetMin(), "integer");
- else if (name == "max_value")
- return new wxProperty("max_value", (long)slider->GetMax(), "integer");
+ else if (name == "minValue")
+ return new wxProperty("minValue", (long)slider->GetMin(), "integer");
+ else if (name == "maxValue")
+ return new wxProperty("maxValue", (long)slider->GetMax(), "integer");
else
return wxItemPropertyInfo::GetProperty(name);
}
return TRUE;
}
- else if (name == "min_value")
+ else if (name == "minValue")
{
slider->SetRange((int)property->GetValue().IntegerValue(), slider->GetMax());
return TRUE;
}
- else if (name == "max_value")
+ else if (name == "maxValue")
{
slider->SetRange(slider->GetMin(), (int)property->GetValue().IntegerValue());
return TRUE;
void wxSliderPropertyInfo::GetPropertyNames(wxStringList& names)
{
+ wxItemPropertyInfo::GetPropertyNames(names);
names.Add("value");
names.Add("orientation");
- names.Add("min_value");
- names.Add("max_value");
- wxItemPropertyInfo::GetPropertyNames(names);
+ names.Add("minValue");
+ names.Add("maxValue");
}
bool wxSliderPropertyInfo::InstantiateResource(wxItemResource *resource)
wxGauge *gauge = (wxGauge *)propertyWindow;
if (name == "value")
return new wxProperty("value", (long)gauge->GetValue(), "integer");
- else if (name == "max_value")
- return new wxProperty("max_value", (long)gauge->GetRange(), "integer");
+ else if (name == "maxValue")
+ return new wxProperty("maxValue", (long)gauge->GetRange(), "integer");
else
return wxItemPropertyInfo::GetProperty(name);
}
gauge->SetValue((int)property->GetValue().IntegerValue());
return TRUE;
}
- else if (name == "max_value")
+ else if (name == "maxValue")
{
gauge->SetRange((int)property->GetValue().IntegerValue());
return TRUE;
void wxGaugePropertyInfo::GetPropertyNames(wxStringList& names)
{
- names.Add("value");
- names.Add("max_value");
wxItemPropertyInfo::GetPropertyNames(names);
+ names.Add("value");
+ names.Add("maxValue");
}
bool wxGaugePropertyInfo::InstantiateResource(wxItemResource *resource)
void wxScrollBarPropertyInfo::GetPropertyNames(wxStringList& names)
{
+ wxItemPropertyInfo::GetPropertyNames(names);
names.Add("orientation");
names.Add("value");
names.Add("pageSize");
names.Add("viewLength");
names.Add("objectLength");
- wxItemPropertyInfo::GetPropertyNames(names);
// Remove some properties we don't inherit
names.Delete("fontPoints");
else
return new wxProperty(name, "Could not get title", "string");
}
+ else if (name == "caption")
+ {
+ return new wxProperty(name, ((panelWindow->GetWindowStyleFlag() & wxCAPTION) == wxCAPTION),
+ "bool");
+ }
+ else if (name == "systemMenu")
+ {
+ return new wxProperty(name, ((panelWindow->GetWindowStyleFlag() & wxSYSTEM_MENU) == wxSYSTEM_MENU),
+ "bool");
+ }
+ else if (name == "thickFrame")
+ {
+ return new wxProperty(name, ((panelWindow->GetWindowStyleFlag() & wxTHICK_FRAME) == wxTHICK_FRAME),
+ "bool");
+ }
else
return wxWindowPropertyInfo::GetProperty(name);
}
else
return FALSE;
}
+ else if (name == "caption")
+ {
+ SetWindowStyle(panelWindow, wxCAPTION, property->GetValue().BoolValue());
+
+ wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow);
+ resource->SetStyle(panelWindow->GetWindowStyleFlag());
+ return TRUE;
+ }
+ else if (name == "thickFrame")
+ {
+ SetWindowStyle(panelWindow, wxTHICK_FRAME, property->GetValue().BoolValue());
+
+ wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow);
+ resource->SetStyle(panelWindow->GetWindowStyleFlag());
+ return TRUE;
+ }
+ else if (name == "systemMenu")
+ {
+ SetWindowStyle(panelWindow, wxSYSTEM_MENU, property->GetValue().BoolValue());
+
+ wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow);
+ resource->SetStyle(panelWindow->GetWindowStyleFlag());
+ return TRUE;
+ }
else
return wxWindowPropertyInfo::SetProperty(name, property);
}
names.Add("title");
names.Add("no3D");
names.Add("backgroundColour");
+ names.Add("caption");
+ names.Add("systemMenu");
+ names.Add("thickFrame");
}
bool wxPanelPropertyInfo::InstantiateResource(wxItemResource *resource)
void wxDialogPropertyInfo::GetPropertyNames(wxStringList& names)
{
+ wxPanelPropertyInfo::GetPropertyNames(names);
names.Add("title");
names.Add("modal");
-
- wxPanelPropertyInfo::GetPropertyNames(names);
}
bool wxDialogPropertyInfo::InstantiateResource(wxItemResource *resource)
wxResourceSymbolDialog* dialog = new wxResourceSymbolDialog(parentWindow, -1, "Edit Symbol");
- dialog->SetSymbol(property->GetValue().StringValue());
+ // Split name/id pair e.g. "IDC_TEXT=123"
+ wxString value(property->GetValue().StringValue());
+
+ wxString strName = value.Before('=');
+ wxString strId = value.After('=');
- // TODO: split name/id pair e.g. "IDC_TEXT=123" or get from symbol table - which?
- dialog->SetId(1234);
+ dialog->SetSymbol(strName);
+ dialog->SetId(atoi(strId));
dialog->Init();
- if (dialog->ShowModal())
+ if (dialog->ShowModal() == wxID_OK)
{
wxString symbolName(dialog->GetSymbol());
long id = dialog->GetId();
dialog->Destroy();
- // TODO: set id somewhere
- property->GetValue() = wxString(symbolName);
+ wxString str;
+ str.Printf("%d", id);
+ property->GetValue() = symbolName + wxString("=") + str;
view->DisplayProperty(property);
view->UpdatePropertyDisplayInList(property);
view->OnPropertyChanged(property);
}
-
-#if 0
- char *s = wxFileSelector(
- filenameMessage.GetData(),
- wxPathOnly(property->GetValue().StringValue()),
- wxFileNameFromPath(property->GetValue().StringValue()),
- NULL,
- filenameWildCard.GetData(),
- 0,
- parentWindow);
- if (s)
- {
- property->GetValue() = wxString(s);
- view->DisplayProperty(property);
- view->UpdatePropertyDisplayInList(property);
- view->OnPropertyChanged(property);
- }
-#endif
}
BEGIN_EVENT_TABLE(wxResourceSymbolDialog, wxDialog)
EVT_BUTTON(wxID_OK, wxResourceSymbolDialog::OnOK)
+ EVT_COMBOBOX(ID_SYMBOLNAME_COMBOBOX, wxResourceSymbolDialog::OnComboBoxSelect)
+ EVT_TEXT(ID_SYMBOLNAME_COMBOBOX, wxResourceSymbolDialog::OnSymbolNameUpdate)
END_EVENT_TABLE()
wxResourceSymbolDialog::wxResourceSymbolDialog(wxWindow* parent, const wxWindowID id, const wxString& title, const wxPoint& pos,
x += 80;
m_nameCtrl = new wxComboBox(this, ID_SYMBOLNAME_COMBOBOX, "",
- wxPoint(x, y), wxSize(200, -1), 0, NULL, wxCB_DROPDOWN);
+ wxPoint(x, y), wxSize(200, -1), 0, NULL, wxCB_DROPDOWN|wxCB_SORT);
y += 30;
x = 5;
y += 30;
x = 5;
- (void) new wxButton(this, wxID_OK, "OK", wxPoint(x, y), wxSize(90, -1));
+ (void) new wxButton(this, wxID_OK, "OK", wxPoint(x, y), wxSize(80, -1));
- x += 120;
- (void) new wxButton(this, wxID_CANCEL, "Cancel", wxPoint(x, y), wxSize(90, -1));
+ x += 100;
+ (void) new wxButton(this, wxID_CANCEL, "Cancel", wxPoint(x, y), wxSize(80, -1));
Fit();
Centre();
m_nameCtrl->SetValue(m_symbolName);
m_idCtrl->SetValue(defaultId);
+
+ wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().FillComboBox(m_nameCtrl);
}
void wxResourceSymbolDialog::OnOK(wxCommandEvent& event)
bool wxResourceSymbolDialog::CheckValues()
{
+ wxString nameStr(m_nameCtrl->GetValue());
+ wxString idStr(m_idCtrl->GetValue());
+ int id = atoi(idStr);
+
+ if (id <= 0 )
+ {
+ wxMessageBox("Identifier cannot be missing or zero", "Dialog Editor", wxOK|wxICON_EXCLAMATION, this);
+ return FALSE;
+ }
+ if (nameStr == "")
+ {
+ wxMessageBox("Please enter a symbol name", "Dialog Editor", wxOK|wxICON_EXCLAMATION, this);
+ return FALSE;
+ }
+ if (nameStr.Contains(" "))
+ {
+ wxMessageBox("Symbol name cannot contain spaces.", "Dialog Editor", wxOK|wxICON_EXCLAMATION, this);
+ return FALSE;
+ }
+ if (nameStr.Contains("="))
+ {
+ wxMessageBox("Symbol name cannot contain =.", "Dialog Editor", wxOK|wxICON_EXCLAMATION, this);
+ return FALSE;
+ }
+ if (nameStr.IsNumber())
+ {
+ wxMessageBox("Symbol name cannot be a number.", "Dialog Editor", wxOK|wxICON_EXCLAMATION, this);
+ return FALSE;
+ }
+ // TODO: other checks on the name syntax.
+
+ if (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(nameStr))
+ {
+ // If we change the id for an existing symbol, we need to:
+ // 1) Check if there are any other resources currently using the original id.
+ // If so, will need to change their id to the new id, in SetProperty.
+ // 2) Remove the old symbol, add the new symbol.
+ // In this check, we don't have to do this, but we need to do it in SetProperty.
+
+ if (nameStr == GetSymbol() && id != GetId())
+ {
+ // It's OK to change the id. But we'll need to change all matching ids in all resources,
+ // in SetProperty.
+ }
+
+ // If we change the name but not the id... we'll just need to remove and
+ // re-add the symbol/id pair, in SetProperty.
+ if (nameStr != GetSymbol() && id == GetId())
+ {
+ }
+
+ // What if we're changing both the name and the id?
+ // - if there's no symbol of that name, just remove the old, add the new (in SetProperty)
+ // - if there is a symbol of that name, if id matches, do nothing. If not, veto.
+
+ if (nameStr != GetSymbol() && id != GetId())
+ {
+ if (!wxResourceManager::GetCurrentResourceManager()->IsIdentifierOK(nameStr, id))
+ {
+ wxMessageBox("This integer id is already being used under a different name.\nPlease choose another.",
+ "Dialog Editor", wxOK|wxICON_EXCLAMATION, this);
+ return FALSE;
+ }
+ }
+
+ }
+
+ SetSymbol(nameStr);
+ SetId(id);
+
return TRUE;
}
+void wxResourceSymbolDialog::OnComboBoxSelect(wxCommandEvent& event)
+{
+ wxString str(m_nameCtrl->GetStringSelection());
+ if (wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(str))
+ {
+ int id = wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetIdForSymbol(str);
+ wxString str2;
+ str2.Printf("%d", id);
+ m_idCtrl->SetValue(str2);
+ m_idCtrl->Enable(FALSE);
+ }
+ else
+ {
+ if (wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().SymbolExists(str))
+ {
+ int id = wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetIdForSymbol(str);
+ wxString str2;
+ str2.Printf("%d", id);
+ m_idCtrl->SetValue(str2);
+ }
+ m_idCtrl->Enable(TRUE);
+ }
+}
+
+void wxResourceSymbolDialog::OnSymbolNameUpdate(wxCommandEvent& event)
+{
+ wxString str(m_nameCtrl->GetValue());
+ if (wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(str))
+ {
+ int id = wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetIdForSymbol(str);
+ wxString str2;
+ str2.Printf("%d", id);
+ m_idCtrl->SetValue(str2);
+ m_idCtrl->Enable(FALSE);
+ }
+ else
+ {
+ if (wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().SymbolExists(str))
+ {
+ int id = wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetIdForSymbol(str);
+ wxString str2;
+ str2.Printf("%d", id);
+ m_idCtrl->SetValue(str2);
+ }
+ m_idCtrl->Enable(TRUE);
+ }
+}
+