Various Dialog Editor-related mods; Dlg Ed. getting usable now under MSW.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@494 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart 1998-08-10 13:48:12 +00:00
parent 983162bd54
commit 9c331ded69
18 changed files with 219 additions and 170 deletions

View File

@ -86,6 +86,9 @@ Add a wxTabCtrl sample.
Improve printing. More API functions for printer DCs (to get Improve printing. More API functions for printer DCs (to get
printer characteristics) and more reliable printing framework. printer characteristics) and more reliable printing framework.
Add GetIcon, GetBitmap to wxImageList. Perhaps store bitmaps
in image list so we can get them later.
LOW PRIORITY LOW PRIORITY
------------ ------------

View File

@ -395,21 +395,14 @@ typedef void (*wxFunction) (wxObject&, wxEvent&);
* Styles for wxListBox * Styles for wxListBox
*/ */
// In wxListBox style flag
#define wxSB_MASK 0x0008
#define wxNEEDED_SB 0x0000
#define wxALWAYS_SB 0x0008
// New naming convention
#define wxLB_NEEDED_SB wxNEEDED_SB
#define wxLB_ALWAYS_SB wxALWAYS_SB
#define wxLB_SORT 0x0010 #define wxLB_SORT 0x0010
// These duplicate the styles in the Multiple argument #define wxLB_SINGLE 0x0020
#define wxLB_SINGLE 0x0000
#define wxLB_MULTIPLE 0x0040 #define wxLB_MULTIPLE 0x0040
#define wxLB_EXTENDED 0x0080 #define wxLB_EXTENDED 0x0080
// wxLB_OWNERDRAW is Windows-only // wxLB_OWNERDRAW is Windows-only
#define wxLB_OWNERDRAW 0x0100 #define wxLB_OWNERDRAW 0x0100
#define wxLB_NEEDED_SB 0x0200
#define wxLB_ALWAYS_SB 0x0400
#define wxLB_HSCROLL wxHSCROLL #define wxLB_HSCROLL wxHSCROLL
/* /*
@ -422,10 +415,6 @@ typedef void (*wxFunction) (wxObject&, wxEvent&);
#define wxTE_READONLY 0x0010 #define wxTE_READONLY 0x0010
#define wxTE_MULTILINE 0x0020 #define wxTE_MULTILINE 0x0020
// TODO For backward compatibility, need wxOLD_READONLY
#define wxREADONLY wxTE_READONLY
#define wxEDITABLE 0
// MSW-only // MSW-only
#define wxTE_RICHTEXT 0x0020 #define wxTE_RICHTEXT 0x0020
@ -433,9 +422,9 @@ typedef void (*wxFunction) (wxObject&, wxEvent&);
* wxComboBox style flags * wxComboBox style flags
*/ */
#define wxCB_SIMPLE 0x0004 #define wxCB_SIMPLE 0x0004
#define wxCB_DROPDOWN 0x0000
#define wxCB_SORT 0x0008 #define wxCB_SORT 0x0008
#define wxCB_READONLY wxREADONLY #define wxCB_READONLY 0x0010
#define wxCB_DROPDOWN 0x0020
/* /*
* wxRadioBox/wxRadioButton style flags * wxRadioBox/wxRadioButton style flags

View File

@ -121,6 +121,8 @@ public:
inline WXHWND *GetRadioButtons(void) const { return m_radioButtons; } inline WXHWND *GetRadioButtons(void) const { return m_radioButtons; }
bool ContainsHWND(WXHWND hWnd) const ; bool ContainsHWND(WXHWND hWnd) const ;
long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
protected: protected:
WXHWND * m_radioButtons; WXHWND * m_radioButtons;
int m_majorDim ; int m_majorDim ;

View File

@ -1790,8 +1790,6 @@ static wxResourceBitListStruct wxResourceBitListTable[] =
{ "wxLB_SINGLE", wxLB_SINGLE }, { "wxLB_SINGLE", wxLB_SINGLE },
{ "wxLB_MULTIPLE", wxLB_MULTIPLE }, { "wxLB_MULTIPLE", wxLB_MULTIPLE },
{ "wxLB_EXTENDED", wxLB_EXTENDED }, { "wxLB_EXTENDED", wxLB_EXTENDED },
{ "wxNEEDED_SB", wxNEEDED_SB },
{ "wxALWAYS_SB", wxALWAYS_SB },
{ "wxLB_NEEDED_SB", wxLB_NEEDED_SB }, { "wxLB_NEEDED_SB", wxLB_NEEDED_SB },
{ "wxLB_ALWAYS_SB", wxLB_ALWAYS_SB }, { "wxLB_ALWAYS_SB", wxLB_ALWAYS_SB },
{ "wxLB_SORT", wxLB_SORT }, { "wxLB_SORT", wxLB_SORT },
@ -1918,8 +1916,6 @@ static wxResourceBitListStruct wxResourceBitListTable[] =
{ "wxDEFAULT_DIALOG_STYLE", wxDEFAULT_DIALOG_STYLE}, { "wxDEFAULT_DIALOG_STYLE", wxDEFAULT_DIALOG_STYLE},
{ "wxBORDER", wxBORDER}, { "wxBORDER", wxBORDER},
{ "wxRETAINED", wxRETAINED}, { "wxRETAINED", wxRETAINED},
{ "wxEDITABLE", wxEDITABLE},
{ "wxREADONLY", wxREADONLY},
{ "wxNATIVE_IMPL", 0}, { "wxNATIVE_IMPL", 0},
{ "wxEXTENDED_IMPL", 0}, { "wxEXTENDED_IMPL", 0},
{ "wxBACKINGSTORE", wxBACKINGSTORE}, { "wxBACKINGSTORE", wxBACKINGSTORE},

View File

@ -82,9 +82,7 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit
// Subclass again for purposes of dialog editing mode // Subclass again for purposes of dialog editing mode
SubclassWin((WXHWND)wx_button); SubclassWin((WXHWND)wx_button);
// TODO? If in future we have a facility for having a label as well SetFont(* parent->GetFont()) ;
// as a bitmap, set the font.
// SetFont(parent->GetFont()) ;
SetSize(x, y, width, height); SetSize(x, y, width, height);
ShowWindow(wx_button, SW_SHOW); ShowWindow(wx_button, SW_SHOW);

View File

@ -245,8 +245,8 @@ void wxChoice::SetSize(int x, int y, int width, int height, int sizeFlags)
} }
// If non-default width... // If non-default width...
if (width >= 0) if (w1 >= 0)
control_width = (float)width; control_width = (float)w1;
control_height = (float)h1; control_height = (float)h1;

View File

@ -74,9 +74,12 @@ void wxControl::SetLabel(const wxString& label)
wxString wxControl::GetLabel(void) const wxString wxControl::GetLabel(void) const
{ {
wxBuffer[0] = 0; wxBuffer[0] = 0;
if (GetHWND()) if (GetHWND())
GetWindowText((HWND)GetHWND(), wxBuffer, 1000); {
int len = GetWindowText((HWND)GetHWND(), wxBuffer, 256);
wxBuffer[len] = 0;
}
return wxString(wxBuffer); return wxString(wxBuffer);
} }

View File

@ -50,6 +50,7 @@ bool wxGauge95::Create(wxWindow *parent, wxWindowID id,
if (parent) parent->AddChild(this); if (parent) parent->AddChild(this);
m_rangeMax = range; m_rangeMax = range;
m_gaugePos = 0;
SetBackgroundColour(parent->GetDefaultBackgroundColour()) ; SetBackgroundColour(parent->GetDefaultBackgroundColour()) ;
SetForegroundColour(parent->GetDefaultForegroundColour()) ; SetForegroundColour(parent->GetDefaultForegroundColour()) ;

View File

@ -85,6 +85,7 @@ bool wxGaugeMSW::Create(wxWindow *parent, wxWindowID id,
if (parent) parent->AddChild(this); if (parent) parent->AddChild(this);
m_rangeMax = range; m_rangeMax = range;
m_gaugePos = 0;
SetBackgroundColour(parent->GetDefaultBackgroundColour()) ; SetBackgroundColour(parent->GetDefaultBackgroundColour()) ;
SetForegroundColour(parent->GetDefaultForegroundColour()) ; SetForegroundColour(parent->GetDefaultForegroundColour()) ;

View File

@ -154,6 +154,10 @@ bool wxSlider95::Create(wxWindow *parent, wxWindowID id,
SubclassWin(GetHWND()); SubclassWin(GetHWND());
SetWindowText((HWND) m_hWnd, "");
SetFont(* parent->GetFont());
if ( m_windowStyle & wxSL_LABELS ) if ( m_windowStyle & wxSL_LABELS )
{ {
// Finally, create max value static item // Finally, create max value static item
@ -163,7 +167,6 @@ bool wxSlider95::Create(wxWindow *parent, wxWindowID id,
0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)NewControlId(), 0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)NewControlId(),
wxGetInstance(), NULL); wxGetInstance(), NULL);
SetFont(parent->GetFont());
if (GetFont()) if (GetFont())
{ {
@ -418,6 +421,11 @@ void wxSlider95::SetSize(int x, int y, int width, int height, int sizeFlags)
else else
{ {
// No labels // No labels
// If we're prepared to use the existing size, then...
if (width == -1 && height == -1 && ((sizeFlags & wxSIZE_AUTO) != wxSIZE_AUTO))
{
GetSize(&w1, &h1);
}
if ( w1 < 0 ) if ( w1 < 0 )
w1 = 200; w1 = 200;
if ( h1 < 0 ) if ( h1 < 0 )
@ -479,6 +487,11 @@ void wxSlider95::SetSize(int x, int y, int width, int height, int sizeFlags)
else else
{ {
// No labels // No labels
// If we're prepared to use the existing size, then...
if (width == -1 && height == -1 && ((sizeFlags & wxSIZE_AUTO) != wxSIZE_AUTO))
{
GetSize(&w1, &h1);
}
if ( w1 < 0 ) if ( w1 < 0 )
w1 = 20; w1 = 20;
if ( h1 < 0 ) if ( h1 < 0 )

View File

@ -77,6 +77,9 @@ bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id,
// Subclass again for purposes of dialog editing mode // Subclass again for purposes of dialog editing mode
SubclassWin((WXHWND) static_item); SubclassWin((WXHWND) static_item);
SetFont(* GetParent()->GetFont());
SetSize(x, y, width, height); SetSize(x, y, width, height);
return TRUE; return TRUE;
} }

View File

@ -213,20 +213,6 @@ void wxStaticBox::OnEraseBackground(wxEraseEvent& event)
long wxStaticBox::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) long wxStaticBox::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
{ {
// TODO: somehow, this has to accept mouse clicks in user interface edit mode,
// but not otherwise. Only there is no longer a UI edit mode...
// It worked before because the message could be processed if not in UI
// edit mode. We have to find some way of distinguishing this.
// Maybe this class can have an AcceptMouseEvents(bool) function; a sort of
// kludge... or, we can search for an active event table entry that will
// intercept mouse events, and if one exists (that isn't the default),
// skip the code below. Too time consuming though.
// Perhaps it's ok to do the default thing *anyway* because the title or edge
// of the window may still be active!
// if (nMsg == WM_NCHITTEST)
// return Default();
if (nMsg == WM_NCHITTEST) if (nMsg == WM_NCHITTEST)
{ {
int xPos = LOWORD(lParam); // horizontal position of cursor int xPos = LOWORD(lParam); // horizontal position of cursor

View File

@ -169,6 +169,9 @@ void wxResourceEditorDialogHandler::OnLeftClick(int x, int y, int keys)
case RESED_CHOICE: case RESED_CHOICE:
resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxChoice", x, y); resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxChoice", x, y);
break; break;
case RESED_COMBOBOX:
resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxComboBox", x, y);
break;
case RESED_CHECKBOX: case RESED_CHECKBOX:
resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxCheckBox", x, y); resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxCheckBox", x, y);
break; break;
@ -204,111 +207,6 @@ void wxResourceEditorDialogHandler::OnLeftClick(int x, int y, int keys)
} }
} }
#if 0
void wxResourceEditorDialogHandler::OnLeftClick(int x, int y, int keys)
{
if (keys & wxKEY_CTRL)
{
wxResourceManager::GetCurrentResourceManager()->EditWindow(handlerDialog);
return;
}
// Deselect all items if click on panel
if (resourceManager->GetEditorPalette()->currentlySelected == PALETTE_ARROW)
{
int needsRefresh = 0;
wxNode *node = handlerDialog->GetChildren()->First();
while (node)
{
wxControl *item = (wxControl *)node->Data();
wxResourceEditorControlHandler *childHandler = (wxResourceEditorControlHandler *)item->GetEventHandler();
if (item->IsKindOf(CLASSINFO(wxControl)) && childHandler->IsSelected())
{
needsRefresh ++;
OnItemSelect(item, FALSE);
childHandler->SelectItem(FALSE);
}
node = node->Next();
}
if (needsRefresh > 0)
{
wxClientDC dc(handlerDialog);
dc.Clear();
handlerDialog->Refresh();
}
return;
}
wxResourceManager* manager = resourceManager;
switch (resourceManager->GetEditorPalette()->currentlySelected)
{
case PALETTE_FRAME:
break;
case PALETTE_DIALOG_BOX:
break;
case PALETTE_PANEL:
break;
case PALETTE_CANVAS:
break;
case PALETTE_TEXT_WINDOW:
break;
case PALETTE_BUTTON:
resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxButton", x, y);
break;
case PALETTE_BITMAP_BUTTON:
resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxButton", x, y, TRUE);
break;
case PALETTE_MESSAGE:
resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxStaticText", x, y);
break;
case PALETTE_BITMAP_MESSAGE:
resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxStaticBitmap", x, y, TRUE);
break;
case PALETTE_TEXT:
resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxTextCtrl (single-line)", x, y);
break;
case PALETTE_MULTITEXT:
resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxTextCtrl (multi-line)", x, y);
break;
case PALETTE_CHOICE:
resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxChoice", x, y);
break;
case PALETTE_CHECKBOX:
resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxCheckBox", x, y);
break;
case PALETTE_RADIOBOX:
resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxRadioBox", x, y);
break;
case PALETTE_LISTBOX:
resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxListBox", x, y);
break;
case PALETTE_SLIDER:
resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxSlider", x, y);
break;
case PALETTE_GAUGE:
resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxGauge", x, y);
break;
case PALETTE_GROUPBOX:
resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxStaticBox", x, y);
break;
case PALETTE_SCROLLBAR:
resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxScrollBar", x, y);
break;
default:
break;
}
// Now switch pointer on.
if (manager->GetEditorPalette()->currentlySelected != PALETTE_ARROW)
{
manager->GetEditorPalette()->ToggleTool(manager->GetEditorPalette()->currentlySelected, FALSE);
manager->GetEditorPalette()->ToggleTool(PALETTE_ARROW, TRUE);
manager->GetEditorPalette()->currentlySelected = PALETTE_ARROW;
}
}
#endif
void wxResourceEditorDialogHandler::OnRightClick(int x, int y, int keys) void wxResourceEditorDialogHandler::OnRightClick(int x, int y, int keys)
{ {
wxMenu *menu = resourceManager->GetPopupMenu(); wxMenu *menu = resourceManager->GetPopupMenu();

View File

@ -993,17 +993,17 @@ bool wxResourceManager::CreatePanelItem(wxItemResource *panelResource, wxPanel *
else if (itemType == "wxMessage" || itemType == "wxStaticText") else if (itemType == "wxMessage" || itemType == "wxStaticText")
{ {
prefix = "ID_STATIC"; prefix = "ID_STATIC";
MakeUniqueName("message", buf); MakeUniqueName("statictext", buf);
res->SetName(buf); res->SetName(buf);
if (isBitmap) if (isBitmap)
newItem = new wxStaticBitmap(panel, -1, m_bitmapImage, wxPoint(x, y), wxSize(0, 0), 0, buf); newItem = new wxStaticBitmap(panel, -1, m_bitmapImage, wxPoint(x, y), wxSize(0, 0), 0, buf);
else else
newItem = new wxStaticText(panel, -1, "Message", wxPoint(x, y), wxSize(-1, -1), 0, buf); newItem = new wxStaticText(panel, -1, "Static", wxPoint(x, y), wxSize(-1, -1), 0, buf);
} }
else if (itemType == "wxStaticBitmap") else if (itemType == "wxStaticBitmap")
{ {
prefix = "ID_STATICBITMAP"; prefix = "ID_STATICBITMAP";
MakeUniqueName("message", buf); MakeUniqueName("static", buf);
res->SetName(buf); res->SetName(buf);
newItem = new wxStaticBitmap(panel, -1, m_bitmapImage, wxPoint(x, y), wxSize(-1, -1), 0, buf); newItem = new wxStaticBitmap(panel, -1, m_bitmapImage, wxPoint(x, y), wxSize(-1, -1), 0, buf);
} }
@ -1047,12 +1047,19 @@ bool wxResourceManager::CreatePanelItem(wxItemResource *panelResource, wxPanel *
res->SetName(buf); res->SetName(buf);
newItem = new wxChoice(panel, -1, wxPoint(x, y), wxSize(-1, -1), 0, NULL, 0, wxDefaultValidator, buf); newItem = new wxChoice(panel, -1, wxPoint(x, y), wxSize(-1, -1), 0, NULL, 0, wxDefaultValidator, buf);
} }
else if (itemType == "wxComboBox")
{
prefix = "ID_COMBOBOX";
MakeUniqueName("combobox", buf);
res->SetName(buf);
newItem = new wxComboBox(panel, -1, "", wxPoint(x, y), wxSize(-1, -1), 0, NULL, wxCB_DROPDOWN, wxDefaultValidator, buf);
}
else if (itemType == "wxGroupBox" || itemType == "wxStaticBox") else if (itemType == "wxGroupBox" || itemType == "wxStaticBox")
{ {
prefix = "ID_STATICBOX"; prefix = "ID_STATICBOX";
MakeUniqueName("group", buf); MakeUniqueName("staticbox", buf);
res->SetName(buf); res->SetName(buf);
newItem = new wxStaticBox(panel, -1, "Groupbox", wxPoint(x, y), wxSize(200, 200), 0, buf); newItem = new wxStaticBox(panel, -1, "Static", wxPoint(x, y), wxSize(200, 200), 0, buf);
} }
else if (itemType == "wxGauge") else if (itemType == "wxGauge")
{ {
@ -1702,8 +1709,12 @@ wxWindow *wxResourceManager::RecreateWindowFromResource(wxWindow *win, wxWindowP
else else
{ {
DisassociateResource(resource); DisassociateResource(resource);
if (win->GetEventHandler() != win)
win->PopEventHandler(TRUE);
DeleteWindow(win); DeleteWindow(win);
newWin = m_resourceTable.CreateItem((wxPanel *)parent, resource); newWin = m_resourceTable.CreateItem((wxPanel *)parent, resource);
newWin->PushEventHandler(new wxResourceEditorControlHandler((wxControl*) newWin, (wxControl*) newWin));
AssociateResource(resource, newWin); AssociateResource(resource, newWin);
UpdateResourceList(); UpdateResourceList();
} }
@ -1860,6 +1871,10 @@ wxWindowPropertyInfo *wxResourceManager::CreatePropertyInfoForWindow(wxWindow *w
{ {
info = new wxChoicePropertyInfo(win); info = new wxChoicePropertyInfo(win);
} }
else if (win->IsKindOf(CLASSINFO(wxComboBox)))
{
info = new wxComboBoxPropertyInfo(win);
}
else if (win->IsKindOf(CLASSINFO(wxButton))) else if (win->IsKindOf(CLASSINFO(wxButton)))
{ {
info = new wxButtonPropertyInfo(win); info = new wxButtonPropertyInfo(win);

View File

@ -214,7 +214,7 @@ bool wxResourceTableWithSaving::SaveResource(ostream& stream, wxItemResource *it
else if (itemType == "wxStaticBox") else if (itemType == "wxStaticBox")
{ {
GenerateControlStyleString(itemType, item->GetStyle(), styleBuf); GenerateControlStyleString(itemType, item->GetStyle(), styleBuf);
stream << item->GetId() << ", " << "wxGroupBox, " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', "; stream << item->GetId() << ", " << "wxStaticBox, " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', ";
stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", "; stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", ";
stream << item->GetWidth() << ", " << item->GetHeight(); stream << item->GetWidth() << ", " << item->GetHeight();
if (item->GetFont()) if (item->GetFont())
@ -329,7 +329,7 @@ bool wxResourceTableWithSaving::SaveResource(ostream& stream, wxItemResource *it
stream << item->GetWidth() << ", " << item->GetHeight(); stream << item->GetWidth() << ", " << item->GetHeight();
if (itemType == "wxComboBox") if (itemType == "wxComboBox")
stream << SafeWord(item->GetValue4()) << ", "; stream << ", " << SafeWord(item->GetValue4());
// Default list of values // Default list of values
@ -509,6 +509,12 @@ bool wxResourceTableWithSaving::SaveResource(ostream& stream, wxItemResource *it
} }
stream << ").\";\n\n"; stream << ").\";\n\n";
} }
else
{
wxString str("Unimplemented resource type: ");
str += itemType;
wxMessageBox(str);
}
return TRUE; return TRUE;
} }

View File

@ -516,7 +516,7 @@ void wxWindowPropertyInfo::GetPropertyNames(wxStringList& names)
// Fill in the wxItemResource members to mirror the current window settings // Fill in the wxItemResource members to mirror the current window settings
bool wxWindowPropertyInfo::InstantiateResource(wxItemResource *resource) bool wxWindowPropertyInfo::InstantiateResource(wxItemResource *resource)
{ {
resource->SetType(propertyWindow->GetClassInfo()->GetClassName()); // resource->SetType(propertyWindow->GetClassInfo()->GetClassName());
// resource->SetStyle(propertyWindow->GetWindowStyleFlag()); // resource->SetStyle(propertyWindow->GetWindowStyleFlag());
wxString str(propertyWindow->GetName()); wxString str(propertyWindow->GetName());
@ -1085,6 +1085,125 @@ bool wxChoicePropertyInfo::InstantiateResource(wxItemResource *resource)
return wxItemPropertyInfo::InstantiateResource(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 * Radiobox item
*/ */
@ -1338,10 +1457,10 @@ wxProperty *wxSliderPropertyInfo::GetProperty(wxString& name)
new wxStringListValidator(new wxStringList("wxHORIZONTAL", "wxVERTICAL", new wxStringListValidator(new wxStringList("wxHORIZONTAL", "wxVERTICAL",
NULL))); NULL)));
} }
else if (name == "min_value") else if (name == "minValue")
return new wxProperty("min_value", (long)slider->GetMin(), "integer"); return new wxProperty("minValue", (long)slider->GetMin(), "integer");
else if (name == "max_value") else if (name == "maxValue")
return new wxProperty("max_value", (long)slider->GetMax(), "integer"); return new wxProperty("maxValue", (long)slider->GetMax(), "integer");
else else
return wxItemPropertyInfo::GetProperty(name); return wxItemPropertyInfo::GetProperty(name);
} }
@ -1386,12 +1505,12 @@ bool wxSliderPropertyInfo::SetProperty(wxString& name, wxProperty *property)
return TRUE; return TRUE;
} }
else if (name == "min_value") else if (name == "minValue")
{ {
slider->SetRange((int)property->GetValue().IntegerValue(), slider->GetMax()); slider->SetRange((int)property->GetValue().IntegerValue(), slider->GetMax());
return TRUE; return TRUE;
} }
else if (name == "max_value") else if (name == "maxValue")
{ {
slider->SetRange(slider->GetMin(), (int)property->GetValue().IntegerValue()); slider->SetRange(slider->GetMin(), (int)property->GetValue().IntegerValue());
return TRUE; return TRUE;
@ -1405,8 +1524,8 @@ void wxSliderPropertyInfo::GetPropertyNames(wxStringList& names)
wxItemPropertyInfo::GetPropertyNames(names); wxItemPropertyInfo::GetPropertyNames(names);
names.Add("value"); names.Add("value");
names.Add("orientation"); names.Add("orientation");
names.Add("min_value"); names.Add("minValue");
names.Add("max_value"); names.Add("maxValue");
} }
bool wxSliderPropertyInfo::InstantiateResource(wxItemResource *resource) bool wxSliderPropertyInfo::InstantiateResource(wxItemResource *resource)
@ -1427,8 +1546,8 @@ wxProperty *wxGaugePropertyInfo::GetProperty(wxString& name)
wxGauge *gauge = (wxGauge *)propertyWindow; wxGauge *gauge = (wxGauge *)propertyWindow;
if (name == "value") if (name == "value")
return new wxProperty("value", (long)gauge->GetValue(), "integer"); return new wxProperty("value", (long)gauge->GetValue(), "integer");
else if (name == "max_value") else if (name == "maxValue")
return new wxProperty("max_value", (long)gauge->GetRange(), "integer"); return new wxProperty("maxValue", (long)gauge->GetRange(), "integer");
else else
return wxItemPropertyInfo::GetProperty(name); return wxItemPropertyInfo::GetProperty(name);
} }
@ -1441,7 +1560,7 @@ bool wxGaugePropertyInfo::SetProperty(wxString& name, wxProperty *property)
gauge->SetValue((int)property->GetValue().IntegerValue()); gauge->SetValue((int)property->GetValue().IntegerValue());
return TRUE; return TRUE;
} }
else if (name == "max_value") else if (name == "maxValue")
{ {
gauge->SetRange((int)property->GetValue().IntegerValue()); gauge->SetRange((int)property->GetValue().IntegerValue());
return TRUE; return TRUE;
@ -1454,7 +1573,7 @@ void wxGaugePropertyInfo::GetPropertyNames(wxStringList& names)
{ {
wxItemPropertyInfo::GetPropertyNames(names); wxItemPropertyInfo::GetPropertyNames(names);
names.Add("value"); names.Add("value");
names.Add("max_value"); names.Add("maxValue");
} }
bool wxGaugePropertyInfo::InstantiateResource(wxItemResource *resource) bool wxGaugePropertyInfo::InstantiateResource(wxItemResource *resource)

View File

@ -214,6 +214,20 @@ class wxChoicePropertyInfo: public wxItemPropertyInfo
bool InstantiateResource(wxItemResource *resource); bool InstantiateResource(wxItemResource *resource);
}; };
// For choice items
class wxComboBoxPropertyInfo: public wxChoicePropertyInfo
{
protected:
public:
wxComboBoxPropertyInfo(wxWindow *win, wxItemResource *res = NULL):
wxChoicePropertyInfo(win, res) {}
~wxComboBoxPropertyInfo(void) {}
wxProperty *GetProperty(wxString& name);
bool SetProperty(wxString& name, wxProperty *property);
void GetPropertyNames(wxStringList& names);
bool InstantiateResource(wxItemResource *resource);
};
// For radiobox items // For radiobox items
class wxRadioBoxPropertyInfo: public wxItemPropertyInfo class wxRadioBoxPropertyInfo: public wxItemPropertyInfo
{ {

View File

@ -248,10 +248,12 @@ static wxWindowStylePair g_WindowStylesWindow[] = {
{ "wxSTATIC_BORDER", wxSTATIC_BORDER}, { "wxSTATIC_BORDER", wxSTATIC_BORDER},
{ "wxTRANSPARENT_WINDOW", wxTRANSPARENT_WINDOW}, { "wxTRANSPARENT_WINDOW", wxTRANSPARENT_WINDOW},
{ "wxNO_BORDER", wxNO_BORDER}, { "wxNO_BORDER", wxNO_BORDER},
{ "wxCLIP_CHILDREN", wxCLIP_CHILDREN}, { "wxCLIP_CHILDREN", wxCLIP_CHILDREN}
{ "wxRETAINED", wxRETAINED},
/* Would be duplicated with e.g. wxLB_HSCROLL
{ "wxVSCROLL", wxVSCROLL }, { "wxVSCROLL", wxVSCROLL },
{ "wxHSCROLL", wxHSCROLL } { "wxHSCROLL", wxHSCROLL }
*/
}; };
int g_WindowStylesWindowCount = sizeof(g_WindowStylesWindow)/sizeof(wxWindowStylePair) ; int g_WindowStylesWindowCount = sizeof(g_WindowStylesWindow)/sizeof(wxWindowStylePair) ;