]>
git.saurik.com Git - wxWidgets.git/blob - contrib/utils/wxrcedit/pe_adv.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Author: Vaclav Slavik
5 // Copyright: (c) 2000 Vaclav Slavik
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
10 #pragma implementation "pe_adv.h"
13 // For compilers that support precompilation, includes "wx/wx.h".
14 #include "wx/wxprec.h"
21 #include "wx/xml/xml.h"
22 #include "wx/tokenzr.h"
24 #include "wx/dialog.h"
25 #include "wx/checklst.h"
31 #include "wx/colordlg.h"
32 #include "wx/config.h"
36 wxWindow
* PropEditCtrlFont::CreateEditCtrl()
38 PropEditCtrlTxt::CreateEditCtrl();
39 m_TextCtrl
->Disable();
45 wxTreeItemId
PropEditCtrlFont::CreateTreeEntry(wxTreeItemId parent
, const PropertyInfo
& pinfo
)
47 wxTreeItemId ti
= PropEditCtrlTxt::CreateTreeEntry(parent
, pinfo
);
48 m_PropFrame
->AddSingleProp(PropertyInfo(_T("integer"), pinfo
.Name
+ _T("/size"), wxEmptyString
), &ti
);
49 m_PropFrame
->AddSingleProp(PropertyInfo(_T("text"), pinfo
.Name
+ _T("/face"), wxEmptyString
), &ti
);
50 m_PropFrame
->AddSingleProp(PropertyInfo(_T("choice"), pinfo
.Name
+ _T("/style"), _T("normal,italic,slant")), &ti
);
51 m_PropFrame
->AddSingleProp(PropertyInfo(_T("choice"), pinfo
.Name
+ _T("/weight"), _T("normal,light,bold")), &ti
);
52 m_PropFrame
->AddSingleProp(PropertyInfo(_T("choice"), pinfo
.Name
+ _T("/family"), _T("default,decorative,roman,script,swiss,modern")), &ti
);
53 m_PropFrame
->AddSingleProp(PropertyInfo(_T("bool"), pinfo
.Name
+ _T("/underlined"), wxEmptyString
), &ti
);
54 m_PropFrame
->AddSingleProp(PropertyInfo(_T("text"), pinfo
.Name
+ _T("/encoding"), wxEmptyString
), &ti
);
63 BEGIN_EVENT_TABLE(PropEditCtrlChoice
, PropEditCtrl
)
64 EVT_CHOICE(wxID_ANY
, PropEditCtrlChoice::OnChoice
)
67 wxWindow
* PropEditCtrlChoice::CreateEditCtrl()
69 m_Choice
= new wxChoice(this, wxID_ANY
);
76 void PropEditCtrlChoice::ReadValue()
78 wxStringTokenizer
tkn(m_PropInfo
->MoreInfo
, _T(","));
80 while (tkn
.HasMoreTokens())
81 m_Choice
->Append(tkn
.GetNextToken());
83 wxString sel
= XmlReadValue(GetNode(), m_PropInfo
->Name
);
84 if (!!sel
) m_Choice
->SetStringSelection(sel
);
89 void PropEditCtrlChoice::WriteValue()
91 XmlWriteValue(GetNode(), m_PropInfo
->Name
,
92 m_Choice
->GetStringSelection());
97 void PropEditCtrlChoice::OnChoice(wxCommandEvent
& WXUNUSED(event
))
102 EditorFrame::Get()->NotifyChanged(CHANGED_PROPS
);
110 void PropEditCtrlColor::OnDetails()
113 wxString txt
= m_TextCtrl
->GetValue();
116 if (txt
.Length() == 7 && txt
[0u] == _T('#') &&
117 wxSscanf(txt
.c_str(), _T("#%lX"), &tmp
) == 1)
118 clr
= wxColour((tmp
& 0xFF0000) >> 16,
119 (tmp
& 0x00FF00) >> 8,
122 clr
= wxGetColourFromUser(NULL
, clr
);
125 txt
.Printf(_T("#%02X%02X%02X"), clr
.Red(), clr
.Green(), clr
.Blue());
126 m_TextCtrl
->SetValue(txt
);
140 void PropEditCtrlFlags::OnDetails()
142 wxString t
,txt
= m_TextCtrl
->GetValue();
147 wxStringTokenizer
tkn(m_PropInfo
->MoreInfo
, _T(","));
148 while (tkn
.HasMoreTokens())
149 arr
.Add(tkn
.GetNextToken());
151 wxConfigBase
*cfg
= wxConfigBase::Get();
153 wxDialog
dlg(m_PropFrame
, wxID_ANY
, _("Flags"),
154 wxPoint(cfg
->Read(_T("flagsdlg_x"), wxDefaultPosition
.x
), cfg
->Read(_T("flagsdlg_y"), wxDefaultPosition
.y
)),
155 wxSize(cfg
->Read(_T("flagsdlg_w"), 300), cfg
->Read(_T("flagsdlg_h"), 300)),
156 wxDEFAULT_DIALOG_STYLE
| wxRESIZE_BORDER
);
157 wxSizer
*sz
= new wxBoxSizer(wxVERTICAL
);
158 wxCheckListBox
*lbox
= new wxCheckListBox(&dlg
, wxID_ANY
);
159 sz
->Add(lbox
, 1, wxEXPAND
| wxALL
, 10);
160 wxSizer
*sz2
= new wxBoxSizer(wxHORIZONTAL
);
161 wxButton
*btnok
= new wxButton(&dlg
, wxID_OK
, _("OK"));
164 sz2
->Add(new wxButton(&dlg
, wxID_CANCEL
, _("Cancel")), 0, wxLEFT
, 10);
165 sz
->Add(sz2
, 0, wxALIGN_RIGHT
| wxRIGHT
| wxBOTTOM
, 10);
170 for (i
= 0; i
< arr
.GetCount(); i
++)
171 lbox
->Append(arr
[i
]);
173 tkn
.SetString(txt
, _T("| "));
174 while (tkn
.HasMoreTokens())
176 t
= tkn
.GetNextToken();
178 if (j
!= wxNOT_FOUND
) lbox
->Check(j
);
182 if (dlg
.ShowModal() != wxID_OK
) return;
186 for (i
= 0; i
< arr
.GetCount(); i
++)
187 if (lbox
->IsChecked(i
))
188 txt
<< arr
[i
] << _T('|');
189 if (!txt
.IsEmpty()) txt
.RemoveLast();
191 m_TextCtrl
->SetValue(txt
);
194 cfg
->Write(_T("flagsdlg_x"), (long)dlg
.GetPosition().x
);
195 cfg
->Write(_T("flagsdlg_y"), (long)dlg
.GetPosition().y
);
196 cfg
->Write(_T("flagsdlg_w"), (long)dlg
.GetSize().x
);
197 cfg
->Write(_T("flagsdlg_h"), (long)dlg
.GetSize().y
);
207 wxString
PropEditCtrlFile::GetFileTypes()
209 return m_PropInfo
->MoreInfo
;
214 void PropEditCtrlFile::OnDetails()
216 wxString txt
= m_TextCtrl
->GetValue();
217 txt
= wxPathOnly(EditorFrame::Get()->GetFileName()) + _T("/") + txt
;
218 wxString name
= wxFileSelector(_("Choose file"),
220 wxFileNameFromPath(txt
),
223 wxOPEN
| wxFILE_MUST_EXIST
);
226 // compute relative path:
227 wxArrayString axrc
, afile
;
228 wxStringTokenizer tkn
;
229 tkn
.SetString(name
, _T("/\\"));
230 while (tkn
.HasMoreTokens()) afile
.Add(tkn
.GetNextToken());
231 tkn
.SetString(EditorFrame::Get()->GetFileName(), _T("/\\"));
232 while (tkn
.HasMoreTokens()) axrc
.Add(tkn
.GetNextToken());
234 if (afile
.GetCount() == 0 || axrc
.GetCount() == 0)
238 while (axrc
[0] == afile
[0])
245 for (i
= 0; i
< axrc
.GetCount()-1/*w/o filename*/; i
++) txt
<< _T("../");
246 for (i
= 0; i
< afile
.GetCount(); i
++) txt
<< afile
[i
] << _T("/");
250 m_TextCtrl
->SetValue(txt
);
256 wxString
PropEditCtrlImageFile::GetFileTypes()
258 return _("GIF files (*.gif)|*.gif|JPEG files (*.jpg)|*.jpg|PNG files (*.png)|*.png|BMP files (*.bmp)|*.bmp|All files (*)|*");