Dialog unit mods; wxProp tidying

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@816 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
1998-10-09 12:01:58 +00:00
parent c39d4bcf2b
commit fd71308fc8
57 changed files with 2060 additions and 1850 deletions

View File

@@ -46,6 +46,7 @@ IMPLEMENT_CLASS(wxResourceEditorControlHandler, wxEvtHandler)
BEGIN_EVENT_TABLE(wxResourceEditorDialogHandler, wxEvtHandler)
EVT_PAINT(wxResourceEditorDialogHandler::OnPaint)
EVT_MOUSE_EVENTS(wxResourceEditorDialogHandler::OnMouseEvent)
EVT_SIZE(wxResourceEditorDialogHandler::OnSize)
END_EVENT_TABLE()
BEGIN_EVENT_TABLE(wxResourceEditorControlHandler, wxEvtHandler)
@@ -292,6 +293,23 @@ void wxResourceEditorDialogHandler::OnItemRightClick(wxControl *item, int x, int
handlerDialog->PopupMenu(menu, x, y);
}
// Under Windows 95, you can resize a panel interactively depending on
// window styles.
void wxResourceEditorDialogHandler::OnSize(wxSizeEvent& event)
{
// Update the associated resource
int w, h;
handlerDialog->GetClientSize(& w, & h);
wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(handlerDialog);
if (resource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS)
{
wxSize sz = handlerDialog->ConvertPixelsToDialog(wxSize(w, h));
w = sz.x; h = sz.y;
}
resource->SetSize(resource->GetX(), resource->GetY(), w, h);
}
// An event outside any items: may be a drag event.
void wxResourceEditorDialogHandler::OnMouseEvent(wxMouseEvent& event)
{
@@ -354,6 +372,15 @@ void wxResourceEditorDialogHandler::OnMouseEvent(wxMouseEvent& event)
OnRightClick(x, y, keys);
}
else if (event.LeftDClick())
{
if (m_mouseCaptured)
{
handlerDialog->ReleaseMouse();
m_mouseCaptured = FALSE;
}
wxResourceManager::GetCurrentResourceManager()->EditWindow(handlerDialog);
}
}
else
event.Skip();
@@ -911,6 +938,9 @@ void wxResourceEditorControlHandler::OnDragEnd(int x, int y, int WXUNUSED(keys),
handlerControl->GetPosition(&xpos, &ypos);
handlerControl->GetSize(&width, &height);
wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(handlerControl);
wxItemResource* parentResource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(handlerControl->GetParent());
if (selectionHandle > 0)
{
int x1, y1, width1, height1;
@@ -967,11 +997,33 @@ void wxResourceEditorControlHandler::OnDragEnd(int x, int y, int WXUNUSED(keys),
break;
}
handlerControl->SetSize(x1, y1, width1, height1);
// Also update the associated resource
// We need to convert to dialog units if this is not a dialog or panel, but
// the parent resource specifies dialog units.
if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS)
{
wxPoint pt = handlerControl->GetParent()->ConvertPixelsToDialog(wxPoint(x1, y1));
x1 = pt.x; y1 = pt.y;
wxSize sz = handlerControl->GetParent()->ConvertPixelsToDialog(wxSize(width1, height1));
width1 = sz.x; height1 = sz.y;
}
resource->SetSize(x1, y1, width1, height1);
}
else
{
handlerControl->Move((int)(x - dragOffsetX), (int)(y - dragOffsetY));
OldOnMove((int)(x - dragOffsetX), (int)(y - dragOffsetY));
int newX = (int)(x - dragOffsetX);
int newY = (int)(y - dragOffsetY);
handlerControl->Move(newX, newY);
OldOnMove(newX, newY);
// Also update the associated resource
if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS)
{
wxPoint pt = handlerControl->GetParent()->ConvertPixelsToDialog(wxPoint(newX, newY));
newX = pt.x; newY = pt.y;
}
resource->SetSize(newX, newY, resource->GetWidth(), resource->GetHeight());
// Also move other selected items
wxNode *node = panel->GetChildren()->First();
@@ -991,6 +1043,16 @@ void wxResourceEditorControlHandler::OnDragEnd(int x, int y, int WXUNUSED(keys),
item->Move(x2, y2);
((wxResourceEditorControlHandler *)item->GetEventHandler())->OldOnMove(x2, y2);
((wxResourceEditorControlHandler *)item->GetEventHandler())->DrawSelectionHandles(dc);
// Also update the associated resource
resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(item);
if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS)
{
wxPoint pt = item->GetParent()->ConvertPixelsToDialog(wxPoint(newX, newY));
x2 = pt.x; y2 = pt.y;
}
resource->SetSize(x2, y2, resource->GetWidth(), resource->GetHeight());
}
}
node = node->Next();

View File

@@ -50,6 +50,7 @@ DECLARE_CLASS(wxResourceEditorDialogHandler)
void OnPaint(wxPaintEvent& event);
void OnMouseEvent(wxMouseEvent& event);
void OnSize(wxSizeEvent& event);
virtual void OnItemEvent(wxControl *win, wxMouseEvent& event);
virtual void OnLeftClick(int x, int y, int keys);

View File

@@ -48,7 +48,7 @@ wxResourceEditorProjectTree::wxResourceEditorProjectTree(wxWindow* parent, wxWin
{
}
void wxResourceEditorProjectTree::LeftDClick(wxMouseEvent& event)
void wxResourceEditorProjectTree::LeftDClick(wxMouseEvent& WXUNUSED(event))
{
#if 0
long sel = GetSelection();
@@ -70,7 +70,7 @@ void wxResourceEditorProjectTree::LeftDClick(wxMouseEvent& event)
#endif
}
void wxResourceEditorProjectTree::OnSelChanged(wxTreeEvent& event)
void wxResourceEditorProjectTree::OnSelChanged(wxTreeEvent& WXUNUSED(event))
{
long sel = GetSelection();
if (sel == -1)

View File

@@ -515,7 +515,7 @@ bool wxResourceManager::DisassociateWindows()
{
m_resourceTable.BeginFind();
wxNode *node;
while (node = m_resourceTable.Next())
while ((node = m_resourceTable.Next()))
{
wxItemResource *res = (wxItemResource *)node->Data();
DisassociateResource(res);
@@ -541,7 +541,7 @@ void wxResourceManager::AssociateResource(wxItemResource *resource, wxWindow *wi
else
{
char buf[200];
sprintf(buf, "AssociateResource: cannot find child window %s", child->GetName() ? child->GetName() : "(unnamed)");
sprintf(buf, "AssociateResource: cannot find child window %s", child->GetName() ? (const char*) child->GetName() : "(unnamed)");
wxMessageBox(buf, "Dialog Editor problem", wxOK);
}
@@ -644,7 +644,7 @@ wxItemResource *wxResourceManager::FindResourceForWindow(wxWindow *win)
{
m_resourceAssociations.BeginFind();
wxNode *node;
while (node = m_resourceAssociations.Next())
while ((node = m_resourceAssociations.Next()))
{
wxWindow *w = (wxWindow *)node->Data();
if (w == win)
@@ -675,8 +675,10 @@ void wxResourceManager::MakeUniqueName(char *prefix, char *buf)
wxFrame *wxResourceManager::OnCreateEditorFrame(const char *title)
{
/*
int frameWidth = 420;
int frameHeight = 300;
*/
wxResourceEditorFrame *frame = new wxResourceEditorFrame(this, NULL, title,
wxPoint(m_resourceEditorWindowSize.x, m_resourceEditorWindowSize.y),
@@ -849,7 +851,7 @@ void wxResourceManager::UpdateResourceList()
m_resourceTable.BeginFind();
wxNode *node;
while (node = m_resourceTable.Next())
while ((node = m_resourceTable.Next()))
{
wxItemResource *res = (wxItemResource *)node->Data();
wxString resType(res->GetType());
@@ -956,6 +958,8 @@ bool wxResourceManager::CreateNewPanel()
resource->SetType("wxDialog");
resource->SetName(buf);
resource->SetTitle(buf);
resource->SetResourceStyle(wxRESOURCE_USE_DEFAULTS);
resource->SetResourceStyle(wxRESOURCE_DIALOG_UNITS);
wxString newIdName;
int id = GenerateWindowId("ID_DIALOG", newIdName);
@@ -966,13 +970,19 @@ bool wxResourceManager::CreateNewPanel()
m_resourceTable.AddResource(resource);
wxSize size(400, 300);
wxPanel *panel = new wxPanel(m_editorPanel, -1,
wxPoint(m_editorPanel->GetMarginX(), m_editorPanel->GetMarginY()),
wxSize(400, 300), wxRAISED_BORDER|wxDEFAULT_DIALOG_STYLE, buf);
size, wxRAISED_BORDER|wxDEFAULT_DIALOG_STYLE, buf);
m_editorPanel->m_childWindow = panel;
resource->SetStyle(panel->GetWindowStyleFlag());
resource->SetSize(10, 10, 400, 300);
// Store dialog units in resource
size = panel->ConvertPixelsToDialog(size);
resource->SetSize(10, 10, size.x, size.y);
// For editing in situ we will need to use the hash table to ensure
// we don't dereference invalid pointers.
@@ -1006,7 +1016,14 @@ bool wxResourceManager::CreatePanelItem(wxItemResource *panelResource, wxPanel *
wxItemResource *res = new wxItemResource;
wxControl *newItem = NULL;
res->SetSize(x, y, -1, -1);
if ((panelResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) != 0)
{
wxPoint pt = panel->ConvertPixelsToDialog(pt);
res->SetSize(pt.x, pt.y, -1, -1);
}
else res->SetSize(x, y, -1, -1);
res->SetType(iType);
wxString prefix;
@@ -1069,7 +1086,7 @@ bool wxResourceManager::CreatePanelItem(wxItemResource *panelResource, wxPanel *
wxString names[] = { "One", "Two" };
newItem = new wxRadioBox(panel, -1, "Radiobox", wxPoint(x, y), wxSize(-1, -1), 2, names, 2,
wxHORIZONTAL, wxDefaultValidator, buf);
res->SetStringValues(new wxStringList("One", "Two", NULL));
res->SetStringValues(wxStringList("One", "Two", NULL));
}
else if (itemType == "wxRadioButton")
{
@@ -1183,16 +1200,13 @@ bool wxResourceManager::TestCurrentDialog(wxWindow* parent)
InstantiateResourceFromWindow(item, m_editorPanel->m_childWindow, TRUE);
wxDialog* dialog = new wxDialog;
long oldStyle = item->GetStyle();
bool success = FALSE;
// item->SetStyle(wxDEFAULT_DIALOG_STYLE);
if (dialog->LoadFromResource(parent, item->GetName(), & m_resourceTable))
{
dialog->Centre();
dialog->ShowModal();
success = TRUE;
}
// item->SetStyle(oldStyle);
return success;
}
return FALSE;
@@ -1204,7 +1218,7 @@ wxWindow *wxResourceManager::FindParentOfSelection()
{
m_resourceTable.BeginFind();
wxNode *node;
while (node = m_resourceTable.Next())
while ((node = m_resourceTable.Next()))
{
wxItemResource *res = (wxItemResource *)node->Data();
wxWindow *win = FindWindowForResource(res);
@@ -1246,7 +1260,7 @@ void wxResourceManager::AlignItems(int flag)
int centreX = (int)(firstX + (firstW / 2));
int centreY = (int)(firstY + (firstH / 2));
while (node = node->Next())
while ((node = node->Next()))
{
wxControl *item = (wxControl *)node->Data();
if (item->GetParent() == win)
@@ -1325,10 +1339,8 @@ void wxResourceManager::CopySize()
int firstW, firstH;
firstSelection->GetPosition(&firstX, &firstY);
firstSelection->GetSize(&firstW, &firstH);
int centreX = (int)(firstX + (firstW / 2));
int centreY = (int)(firstY + (firstH / 2));
while (node = node->Next())
while ((node = node->Next()))
{
wxControl *item = (wxControl *)node->Data();
if (item->GetParent() == win)
@@ -1389,7 +1401,7 @@ bool wxResourceManager::RemoveResourceFromParent(wxItemResource *res)
{
m_resourceTable.BeginFind();
wxNode *node;
while (node = m_resourceTable.Next())
while ((node = m_resourceTable.Next()))
{
wxItemResource *thisRes = (wxItemResource *)node->Data();
if (thisRes->GetChildren().Member(res))
@@ -1420,11 +1432,13 @@ bool wxResourceManager::DeleteResource(wxItemResource *res)
// If this is a button or message resource, delete the
// associate bitmap resource if not being used.
wxString resType(res->GetType());
/* shouldn't have to do this now bitmaps are ref-counted
if ((resType == "wxMessage" || resType == "wxStaticBitmap" || resType == "wxButton" || resType == "wxBitmapButton") && res->GetValue4())
{
PossiblyDeleteBitmapResource(res->GetValue4());
}
*/
// Remove symbol from table if appropriate
if (!IsSymbolUsed(res, res->GetId()))
@@ -1467,7 +1481,7 @@ bool wxResourceManager::DeleteResource(wxWindow *win)
// Will eventually have bitmap type information, for different
// kinds of bitmap.
char *wxResourceManager::AddBitmapResource(char *filename)
wxString wxResourceManager::AddBitmapResource(const wxString& filename)
{
wxItemResource *resource = FindBitmapResourceByFilename(filename);
if (!resource)
@@ -1496,11 +1510,11 @@ char *wxResourceManager::AddBitmapResource(char *filename)
if (resource)
return resource->GetName();
else
return NULL;
return wxEmptyString;
}
// Delete the bitmap resource if it isn't being used by another resource.
void wxResourceManager::PossiblyDeleteBitmapResource(char *resourceName)
void wxResourceManager::PossiblyDeleteBitmapResource(const wxString& resourceName)
{
if (!IsBitmapResourceUsed(resourceName))
{
@@ -1510,11 +1524,11 @@ void wxResourceManager::PossiblyDeleteBitmapResource(char *resourceName)
}
}
bool wxResourceManager::IsBitmapResourceUsed(char *resourceName)
bool wxResourceManager::IsBitmapResourceUsed(const wxString& resourceName)
{
m_resourceTable.BeginFind();
wxNode *node;
while (node = m_resourceTable.Next())
while ((node = m_resourceTable.Next()))
{
wxItemResource *res = (wxItemResource *)node->Data();
wxString resType(res->GetType());
@@ -1538,13 +1552,13 @@ bool wxResourceManager::IsBitmapResourceUsed(char *resourceName)
}
// Given a wxButton or wxMessage, find the corresponding bitmap filename.
char *wxResourceManager::FindBitmapFilenameForResource(wxItemResource *resource)
wxString wxResourceManager::FindBitmapFilenameForResource(wxItemResource *resource)
{
if (!resource || !resource->GetValue4())
return NULL;
if (!resource || (resource->GetValue4() == ""))
return wxEmptyString;
wxItemResource *bitmapResource = m_resourceTable.FindResource(resource->GetValue4());
if (!bitmapResource)
return NULL;
return wxEmptyString;
wxNode *node = bitmapResource->GetChildren().First();
while (node)
@@ -1557,14 +1571,14 @@ char *wxResourceManager::FindBitmapFilenameForResource(wxItemResource *resource)
node = node->Next();
}
return NULL;
return wxEmptyString;
}
wxItemResource *wxResourceManager::FindBitmapResourceByFilename(char *filename)
wxItemResource *wxResourceManager::FindBitmapResourceByFilename(const wxString& filename)
{
m_resourceTable.BeginFind();
wxNode *node;
while (node = m_resourceTable.Next())
while ((node = m_resourceTable.Next()))
{
wxItemResource *res = (wxItemResource *)node->Data();
wxString resType(res->GetType());
@@ -1591,7 +1605,7 @@ bool wxResourceManager::IsSymbolUsed(wxItemResource* thisResource, wxWindowID id
{
m_resourceTable.BeginFind();
wxNode *node;
while (node = m_resourceTable.Next())
while ((node = m_resourceTable.Next()))
{
wxItemResource *res = (wxItemResource *)node->Data();
@@ -1634,7 +1648,7 @@ void wxResourceManager::ChangeIds(int oldId, int newId)
{
m_resourceTable.BeginFind();
wxNode *node;
while (node = m_resourceTable.Next())
while ((node = m_resourceTable.Next()))
{
wxItemResource *res = (wxItemResource *)node->Data();
@@ -1666,7 +1680,7 @@ bool wxResourceManager::RepairResourceIds()
m_resourceTable.BeginFind();
wxNode *node;
while (node = m_resourceTable.Next())
while ((node = m_resourceTable.Next()))
{
wxItemResource *res = (wxItemResource *)node->Data();
wxString resType(res->GetType());
@@ -1742,6 +1756,9 @@ wxWindow *wxResourceManager::RecreateWindowFromResource(wxWindow *win, wxWindowP
wxWindow *newWin = NULL;
wxWindow *parent = win->GetParent();
wxItemResource* parentResource = NULL;
if (parent)
FindResourceForWindow(parent);
if (win->IsKindOf(CLASSINFO(wxPanel)))
{
@@ -1755,7 +1772,7 @@ wxWindow *wxResourceManager::RecreateWindowFromResource(wxWindow *win, wxWindowP
win->PopEventHandler(TRUE);
DeleteWindow(win);
newWin = m_resourceTable.CreateItem((wxPanel *)parent, resource);
newWin = m_resourceTable.CreateItem((wxPanel *)parent, resource, parentResource);
newWin->PushEventHandler(new wxResourceEditorControlHandler((wxControl*) newWin, (wxControl*) newWin));
AssociateResource(resource, newWin);
UpdateResourceList();
@@ -1811,7 +1828,7 @@ bool wxResourceManager::RecreateSelection()
return TRUE;
}
bool wxResourceManager::EditDialog(wxDialog *dialog, wxWindow *parent)
bool wxResourceManager::EditDialog(wxDialog *WXUNUSED(dialog), wxWindow *WXUNUSED(parent))
{
return FALSE;
}
@@ -1822,7 +1839,7 @@ bool wxResourceManager::InstantiateAllResourcesFromWindows()
{
m_resourceTable.BeginFind();
wxNode *node;
while (node = m_resourceTable.Next())
while ((node = m_resourceTable.Next()))
{
wxItemResource *res = (wxItemResource *)node->Data();
wxString resType(res->GetType());
@@ -1861,7 +1878,7 @@ bool wxResourceManager::InstantiateResourceFromWindow(wxItemResource *resource,
if (!childWindow)
{
char buf[200];
sprintf(buf, "Could not find window %s", child->GetName());
sprintf(buf, "Could not find window %s", (const char*) child->GetName());
wxMessageBox(buf, "Dialog Editor problem", wxOK);
}
else
@@ -2231,7 +2248,7 @@ EditorToolBar::EditorToolBar(wxFrame *frame, const wxPoint& pos, const wxSize& s
{
}
bool EditorToolBar::OnLeftClick(int toolIndex, bool toggled)
bool EditorToolBar::OnLeftClick(int toolIndex, bool WXUNUSED(toggled))
{
wxResourceManager *manager = wxResourceManager::GetCurrentResourceManager();

View File

@@ -117,7 +117,7 @@ class wxResourceTableWithSaving: public wxResourceTable
m_styleTable.Init();
}
virtual bool Save(const wxString& filename);
virtual bool SaveResource(ostream& stream, wxItemResource *item);
virtual bool SaveResource(ostream& stream, wxItemResource* item, wxItemResource* parentItem);
void GeneratePanelStyleString(long windowStyle, char *buf);
void GenerateDialogStyleString(long windowStyle, char *buf);
@@ -144,8 +144,8 @@ class wxResourceTableWithSaving: public wxResourceTable
bool GenerateStyle(char *buf, long windowStyle, long flag, char *strStyle);
*/
void OutputFont(ostream& stream, wxFont *font);
wxControl *CreateItem(wxPanel *panel, wxItemResource *childResource);
void OutputFont(ostream& stream, const wxFont& font);
wxControl *CreateItem(wxPanel *panel, const wxItemResource *childResource, const wxItemResource* parentResource);
protected:
wxWindowStyleTable m_styleTable;
@@ -219,17 +219,17 @@ public:
virtual bool DeleteResource(wxWindow *win);
// Add bitmap resource if there isn't already one with this filename.
virtual char *AddBitmapResource(char *filename);
virtual wxString AddBitmapResource(const wxString& filename);
// Delete the bitmap resource if it isn't being used by another resource.
virtual void PossiblyDeleteBitmapResource(char *resourceName);
virtual void PossiblyDeleteBitmapResource(const wxString& resourceName);
// Helper function for above
virtual bool IsBitmapResourceUsed(char *resourceName);
virtual bool IsBitmapResourceUsed(const wxString& resourceName);
wxItemResource *FindBitmapResourceByFilename(char *filename);
wxItemResource *FindBitmapResourceByFilename(const wxString& filename);
char *FindBitmapFilenameForResource(wxItemResource *resource);
wxString FindBitmapFilenameForResource(wxItemResource *resource);
// Is this window identifier in use?
bool IsSymbolUsed(wxItemResource* thisResource, wxWindowID id) ;

View File

@@ -43,27 +43,27 @@
#include "reseditr.h"
char *SafeString(char *s);
char *SafeWord(char *s);
char *SafeWord(const wxString& s);
// Save an association between the child resource and the panel item, to allow
// us not to require unique window names.
wxControl *wxResourceTableWithSaving::CreateItem(wxPanel *panel, wxItemResource *childResource)
wxControl *wxResourceTableWithSaving::CreateItem(wxPanel *panel, const wxItemResource *childResource, const wxItemResource* parentResource)
{
wxControl *item = wxResourceTable::CreateItem(panel, childResource);
wxControl *item = wxResourceTable::CreateItem(panel, childResource, parentResource);
if (item)
wxResourceManager::GetCurrentResourceManager()->GetResourceAssociations().Put((long)childResource, item);
return item;
}
void wxResourceTableWithSaving::OutputFont(ostream& stream, wxFont *font)
void wxResourceTableWithSaving::OutputFont(ostream& stream, const wxFont& font)
{
stream << "[" << font->GetPointSize() << ", '";
stream << font->GetFamilyString() << "', '";
stream << font->GetStyleString() << "', '";
stream << font->GetWeightString() << "', ";
stream << (int)font->GetUnderlined();
if (font->GetFaceName() != "")
stream << ", '" << font->GetFaceName() << "'";
stream << "[" << font.GetPointSize() << ", '";
stream << font.GetFamilyString() << "', '";
stream << font.GetStyleString() << "', '";
stream << font.GetWeightString() << "', ";
stream << (int)font.GetUnderlined();
if (font.GetFaceName() != "")
stream << ", '" << font.GetFaceName() << "'";
stream << "]";
}
@@ -79,21 +79,21 @@ bool wxResourceTableWithSaving::Save(const wxString& filename)
BeginFind();
wxNode *node = NULL;
while (node = Next())
while ((node = Next()))
{
wxItemResource *item = (wxItemResource *)node->Data();
wxString resType(item->GetType());
if (resType == "wxDialogBox" || resType == "wxDialog" || resType == "wxPanel" || resType == "wxBitmap")
{
if (!SaveResource(stream, item))
if (!SaveResource(stream, item, (wxItemResource*) NULL))
return FALSE;
}
}
return TRUE;
}
bool wxResourceTableWithSaving::SaveResource(ostream& stream, wxItemResource *item)
bool wxResourceTableWithSaving::SaveResource(ostream& stream, wxItemResource* item, wxItemResource* parentItem)
{
char styleBuf[400];
wxString itemType(item->GetType());
@@ -110,6 +110,7 @@ bool wxResourceTableWithSaving::SaveResource(ostream& stream, wxItemResource *it
stream << "static char *" << item->GetName() << " = \"panel(name = '" << item->GetName() << "',\\\n";
GenerateDialogStyleString(item->GetStyle(), styleBuf);
}
stream << " style = '" << styleBuf << "',\\\n";
stream << " title = '" << item->GetTitle() << "',\\\n";
stream << " id = " << item->GetId() << ",\\\n";
@@ -118,19 +119,29 @@ bool wxResourceTableWithSaving::SaveResource(ostream& stream, wxItemResource *it
if (1) // item->GetStyle() & wxNO_3D)
{
if (item->GetBackgroundColour())
if (item->GetBackgroundColour().Ok())
{
char buf[7];
wxDecToHex(item->GetBackgroundColour()->Red(), buf);
wxDecToHex(item->GetBackgroundColour()->Green(), buf+2);
wxDecToHex(item->GetBackgroundColour()->Blue(), buf+4);
wxDecToHex(item->GetBackgroundColour().Red(), buf);
wxDecToHex(item->GetBackgroundColour().Green(), buf+2);
wxDecToHex(item->GetBackgroundColour().Blue(), buf+4);
buf[6] = 0;
stream << ",\\\n " << "background_colour = '" << buf << "'";
}
}
int dialogUnits = 0;
int useDefaults = 0;
if ((item->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) != 0)
dialogUnits = 1;
if ((item->GetResourceStyle() & wxRESOURCE_USE_DEFAULTS) != 0)
useDefaults = 1;
stream << ",\\\n " << "use_dialog_units = " << dialogUnits;
stream << ",\\\n " << "use_system_defaults = " << useDefaults;
if (item->GetFont() && item->GetFont()->Ok())
if (item->GetFont().Ok())
{
stream << ",\\\n font = ";
OutputFont(stream, item->GetFont());
@@ -147,7 +158,7 @@ bool wxResourceTableWithSaving::SaveResource(ostream& stream, wxItemResource *it
stream << " control = [";
SaveResource(stream, child);
SaveResource(stream, child, item);
stream << "]";
@@ -165,7 +176,7 @@ bool wxResourceTableWithSaving::SaveResource(ostream& stream, wxItemResource *it
stream << item->GetWidth() << ", " << item->GetHeight();
if (item->GetValue4())
stream << ", '" << item->GetValue4() << "'";
if (item->GetFont())
if (item->GetFont().Ok())
{
stream << ",\\\n ";
OutputFont(stream, item->GetFont());
@@ -179,7 +190,7 @@ bool wxResourceTableWithSaving::SaveResource(ostream& stream, wxItemResource *it
stream << item->GetWidth() << ", " << item->GetHeight();
if (item->GetValue4())
stream << ", '" << item->GetValue4() << "'";
if (item->GetFont())
if (item->GetFont().Ok())
{
stream << ",\\\n ";
OutputFont(stream, item->GetFont());
@@ -192,7 +203,7 @@ bool wxResourceTableWithSaving::SaveResource(ostream& stream, wxItemResource *it
stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", ";
stream << item->GetWidth() << ", " << item->GetHeight();
stream << ", " << item->GetValue1();
if (item->GetFont())
if (item->GetFont().Ok())
{
stream << ",\\\n ";
OutputFont(stream, item->GetFont());
@@ -205,7 +216,7 @@ bool wxResourceTableWithSaving::SaveResource(ostream& stream, wxItemResource *it
stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", ";
stream << item->GetWidth() << ", " << item->GetHeight();
stream << ", " << item->GetValue1();
if (item->GetFont())
if (item->GetFont().Ok())
{
stream << ",\\\n ";
OutputFont(stream, item->GetFont());
@@ -217,7 +228,7 @@ bool wxResourceTableWithSaving::SaveResource(ostream& stream, wxItemResource *it
stream << item->GetId() << ", " << "wxStaticBox, " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', ";
stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", ";
stream << item->GetWidth() << ", " << item->GetHeight();
if (item->GetFont())
if (item->GetFont().Ok())
{
stream << ",\\\n ";
OutputFont(stream, item->GetFont());
@@ -231,7 +242,7 @@ bool wxResourceTableWithSaving::SaveResource(ostream& stream, wxItemResource *it
stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", ";
stream << item->GetWidth() << ", " << item->GetHeight();
stream << ", " << SafeWord(item->GetValue4());
if (item->GetFont())
if (item->GetFont().Ok())
{
stream << ",\\\n ";
OutputFont(stream, item->GetFont());
@@ -244,7 +255,7 @@ bool wxResourceTableWithSaving::SaveResource(ostream& stream, wxItemResource *it
stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", ";
stream << item->GetWidth() << ", " << item->GetHeight();
stream << ", " << item->GetValue1() << ", " << item->GetValue2();
if (item->GetFont())
if (item->GetFont().Ok())
{
stream << ",\\\n ";
OutputFont(stream, item->GetFont());
@@ -257,7 +268,7 @@ bool wxResourceTableWithSaving::SaveResource(ostream& stream, wxItemResource *it
stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", ";
stream << item->GetWidth() << ", " << item->GetHeight();
stream << ", " << item->GetValue1() << ", " << item->GetValue2() << ", " << item->GetValue3();
if (item->GetFont())
if (item->GetFont().Ok())
{
stream << ",\\\n ";
OutputFont(stream, item->GetFont());
@@ -282,9 +293,9 @@ bool wxResourceTableWithSaving::SaveResource(ostream& stream, wxItemResource *it
// Default list of values
stream << ", [";
if (item->GetStringValues())
if (item->GetStringValues().Number() > 0)
{
wxNode *node = item->GetStringValues()->First();
wxNode *node = item->GetStringValues().First();
while (node)
{
char *s = (char *)node->Data();
@@ -314,7 +325,7 @@ bool wxResourceTableWithSaving::SaveResource(ostream& stream, wxItemResource *it
break;
}
}
if (item->GetFont())
if (item->GetFont().Ok())
{
stream << ",\\\n ";
OutputFont(stream, item->GetFont());
@@ -334,9 +345,9 @@ bool wxResourceTableWithSaving::SaveResource(ostream& stream, wxItemResource *it
// Default list of values
stream << ", [";
if (item->GetStringValues())
if (item->GetStringValues().Number() > 0)
{
wxNode *node = item->GetStringValues()->First();
wxNode *node = item->GetStringValues().First();
while (node)
{
char *s = (char *)node->Data();
@@ -347,7 +358,7 @@ bool wxResourceTableWithSaving::SaveResource(ostream& stream, wxItemResource *it
}
}
stream << "]";
if (item->GetFont())
if (item->GetFont().Ok())
{
stream << ",\\\n ";
OutputFont(stream, item->GetFont());
@@ -364,9 +375,9 @@ bool wxResourceTableWithSaving::SaveResource(ostream& stream, wxItemResource *it
// Default list of values
stream << ", [";
if (item->GetStringValues())
if (item->GetStringValues().Number() > 0)
{
wxNode *node = item->GetStringValues()->First();
wxNode *node = item->GetStringValues().First();
while (node)
{
char *s = (char *)node->Data();
@@ -377,7 +388,7 @@ bool wxResourceTableWithSaving::SaveResource(ostream& stream, wxItemResource *it
}
}
stream << "], " << item->GetValue1();
if (item->GetFont())
if (item->GetFont().Ok())
{
stream << ",\\\n ";
OutputFont(stream, item->GetFont());
@@ -552,9 +563,9 @@ void wxResourceTableWithSaving::GenerateControlStyleString(const wxString& windo
}
// Returns quoted string or "NULL"
char *SafeString(char *s)
char *SafeString(const wxString& s)
{
if (!s)
if (s == "")
return "NULL";
else
{
@@ -566,14 +577,14 @@ char *SafeString(char *s)
}
// Returns quoted string or ''
char *SafeWord(char *s)
char *SafeWord(const wxString& s)
{
if (!s)
if (s == "")
return "''";
else
{
strcpy(wxBuffer, "'");
strcat(wxBuffer, s);
strcat(wxBuffer, (const char*) s);
strcat(wxBuffer, "'");
return wxBuffer;
}

View File

@@ -70,7 +70,7 @@ bool wxResourceSymbolTable::ReadIncludeFile(const wxString& filename)
str.UngetWriteBuf();
// Look for #define occurrences
size_t pos = str.Find("#define");
int pos = str.Find("#define");
while (pos != -1)
{
size_t len = str.Length();

File diff suppressed because it is too large Load Diff

View File

@@ -40,15 +40,16 @@ private:
class wxResourcePropertyListView: public wxPropertyListView
{
public:
wxPropertyInfo *propertyInfo;
wxResourcePropertyListView(wxPropertyInfo *info, wxPanel *propPanel = NULL, long flags = wxPROP_BUTTON_DEFAULT):
wxPropertyListView(propPanel, flags)
{
propertyInfo = info;
m_propertyInfo = info;
}
void OnPropertyChanged(wxProperty *property);
bool OnClose(void);
wxPropertyInfo* m_propertyInfo;
};
// Generic class for relating an object to a collection of properties.
@@ -76,9 +77,6 @@ class wxPropertyInfo: public wxObject
// For all windows
class wxWindowPropertyInfo: public wxPropertyInfo
{
protected:
wxWindow *propertyWindow;
wxItemResource *propertyResource;
public:
wxWindowPropertyInfo(wxWindow *win, wxItemResource *res = NULL);
~wxWindowPropertyInfo(void);
@@ -86,9 +84,9 @@ class wxWindowPropertyInfo: public wxPropertyInfo
bool SetProperty(wxString& name, wxProperty *property);
void GetPropertyNames(wxStringList& names);
inline void SetPropertyWindow(wxWindow *win) { propertyWindow = win; }
inline void SetPropertyWindow(wxWindow *win) { m_propertyWindow = win; }
inline void SetResource(wxItemResource *res) { propertyResource = res; }
inline void SetResource(wxItemResource *res) { m_propertyResource = res; }
// Helper functions for font properties
@@ -100,6 +98,10 @@ class wxWindowPropertyInfo: public wxPropertyInfo
// Set the window style
void SetWindowStyle(wxWindow* win, long style, bool set);
protected:
wxWindow* m_propertyWindow;
wxItemResource* m_propertyResource;
};
// For panel items
@@ -338,6 +340,9 @@ class wxPanelPropertyInfo: public wxWindowPropertyInfo
bool SetProperty(wxString& name, wxProperty *property);
void GetPropertyNames(wxStringList& names);
bool InstantiateResource(wxItemResource *resource);
// Convert this dialog, and its children, to or from dialog units
void ConvertDialogUnits(bool toDialogUnits);
};
int wxStringToFontWeight(wxString& val);