• R/O
  • HTTP
  • SSH
  • HTTPS

Molby: コミット

Molecular Modeling Software


コミットメタ情報

リビジョン052aea8a36f671ad2c4d350ef7c446e868cc123f (tree)
日時2022-09-12 23:13:14
作者Toshi Nagata <alchemist.2005@nift...>
コミッターToshi Nagata

ログメッセージ

Mac target is now buildable (not working yet)

変更サマリ

差分

--- a/MolLib/Types.h
+++ b/MolLib/Types.h
@@ -27,8 +27,8 @@
2727
2828 #if defined(__WXMAC__) || defined(__CMDMAC__)
2929 /* On Mac OS X, CLAPACK is in Accelerate.framework */
30-#include <vecLib/cblas.h>
31-#include <vecLib/clapack.h>
30+#include <cblas.h>
31+#include <clapack.h>
3232 //#include <Accelerate/Accelerate.h>
3333 #else
3434 #include <f2c.h>
--- a/build-xcode/Molby.xcodeproj/project.pbxproj
+++ b/build-xcode/Molby.xcodeproj/project.pbxproj
@@ -24,6 +24,7 @@
2424 /* End PBXAggregateTarget section */
2525
2626 /* Begin PBXBuildFile section */
27+ E403568428CF6A3D008E2C46 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E403568328CF6A3D008E2C46 /* QuartzCore.framework */; };
2728 E4059F9B28C46A6E0052B36B /* molby_icon.icns in Resources */ = {isa = PBXBuildFile; fileRef = E4FC77D4183E4FF20064FB2E /* molby_icon.icns */; };
2829 E4059F9C28C46A6E0052B36B /* Scripts in Resources */ = {isa = PBXBuildFile; fileRef = E4FC77D6183E4FFE0064FB2E /* Scripts */; };
2930 E4059F9D28C46A6E0052B36B /* amber11 in Resources */ = {isa = PBXBuildFile; fileRef = E4FC77D8183E503E0064FB2E /* amber11 */; };
@@ -92,7 +93,6 @@
9293 E4059FDE28C46A6E0052B36B /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E4FC7B58183E53710064FB2E /* WebKit.framework */; };
9394 E4059FDF28C46A6E0052B36B /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E4FC7CAC183F953E0064FB2E /* AudioToolbox.framework */; };
9495 E4059FE728C46B330052B36B /* Molby_MacLegacy-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = E4059FE628C46B320052B36B /* Molby_MacLegacy-Info.plist */; };
95- E41251B628C4B1AB00E12983 /* listctrl_wx32.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E41251B528C4B1AB00E12983 /* listctrl_wx32.cpp */; };
9696 E41251B828CD92A100E12983 /* MyListCtrl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E41251B728CD92A100E12983 /* MyListCtrl.cpp */; };
9797 E41251B928CD92A100E12983 /* MyListCtrl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E41251B728CD92A100E12983 /* MyListCtrl.cpp */; };
9898 E41A7F962307D61200C65830 /* bitmaps in Resources */ = {isa = PBXBuildFile; fileRef = E41A7F952307D61200C65830 /* bitmaps */; };
@@ -114,7 +114,6 @@
114114 E420BE22188574F600A2B983 /* ProgressFrame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E420BE1D188574F600A2B983 /* ProgressFrame.cpp */; };
115115 E420BE23188574F600A2B983 /* RubyDialogFrame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E420BE1F188574F600A2B983 /* RubyDialogFrame.cpp */; };
116116 E420BE24188574F600A2B983 /* wxKillAddition.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E420BE21188574F600A2B983 /* wxKillAddition.cpp */; };
117- E45B94621A170B9A008E95EB /* docview.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E45B94611A170B9A008E95EB /* docview.cpp */; };
118117 E4653CB118A0CC7D0022377B /* textctrl_addition.mm in Sources */ = {isa = PBXBuildFile; fileRef = E4653CB018A0CC7D0022377B /* textctrl_addition.mm */; };
119118 E4ACACE718C6D32300F08B67 /* ortep3 in Resources */ = {isa = PBXBuildFile; fileRef = E4ACACE418C6D32300F08B67 /* ortep3 */; };
120119 E4D379A219C87C2200636D28 /* modalwindow.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4D379A119C87C2200636D28 /* modalwindow.cpp */; };
@@ -186,9 +185,9 @@
186185
187186 /* Begin PBXFileReference section */
188187 8D1107320486CEB800E47090 /* Molby.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Molby.app; sourceTree = BUILT_PRODUCTS_DIR; };
188+ E403568328CF6A3D008E2C46 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = /System/Library/Frameworks/QuartzCore.framework; sourceTree = "<absolute>"; };
189189 E4059FE428C46A6E0052B36B /* Molby_MacLegacy.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Molby_MacLegacy.app; sourceTree = BUILT_PRODUCTS_DIR; };
190190 E4059FE628C46B320052B36B /* Molby_MacLegacy-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Molby_MacLegacy-Info.plist"; sourceTree = "<group>"; };
191- E41251B528C4B1AB00E12983 /* listctrl_wx32.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = listctrl_wx32.cpp; sourceTree = "<group>"; };
192191 E41251B728CD92A100E12983 /* MyListCtrl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MyListCtrl.cpp; sourceTree = "<group>"; };
193192 E41251BA28CD92AD00E12983 /* MyListCtrl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MyListCtrl.h; sourceTree = "<group>"; };
194193 E4196C65190B2FA500183E62 /* menu.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = menu.mm; sourceTree = "<group>"; };
@@ -316,6 +315,7 @@
316315 files = (
317316 E4FC7811183E50DC0064FB2E /* Accelerate.framework in Frameworks */,
318317 E4FC7838183E50F00064FB2E /* AGL.framework in Frameworks */,
318+ E403568428CF6A3D008E2C46 /* QuartzCore.framework in Frameworks */,
319319 E4FC784C183E51180064FB2E /* Carbon.framework in Frameworks */,
320320 E4FC784D183E51180064FB2E /* Cocoa.framework in Frameworks */,
321321 E4FC784E183E51180064FB2E /* GLUT.framework in Frameworks */,
@@ -489,6 +489,7 @@
489489 E4FC780D183E50AF0064FB2E /* Linked Frameworks */ = {
490490 isa = PBXGroup;
491491 children = (
492+ E403568328CF6A3D008E2C46 /* QuartzCore.framework */,
492493 E4FC7CAC183F953E0064FB2E /* AudioToolbox.framework */,
493494 E4FC7810183E50DC0064FB2E /* Accelerate.framework */,
494495 E4FC7837183E50F00064FB2E /* AGL.framework */,
@@ -526,7 +527,6 @@
526527 E420BDEE1885746700A2B983 /* GlobalParameterFrame.h */,
527528 E420BDF31885749000A2B983 /* listctrl_private.h */,
528529 E420BDF41885749000A2B983 /* listctrl.cpp */,
529- E41251B528C4B1AB00E12983 /* listctrl_wx32.cpp */,
530530 E4653CB018A0CC7D0022377B /* textctrl_addition.mm */,
531531 E4196C65190B2FA500183E62 /* menu.mm */,
532532 E420BDF51885749000A2B983 /* MoleculeView.cpp */,
@@ -877,7 +877,6 @@
877877 E4FC77B7183E4F3F0064FB2E /* Object.c in Sources */,
878878 E4FC77B8183E4F3F0064FB2E /* Parameter.c in Sources */,
879879 E4FC77BA183E4F3F0064FB2E /* ruby_bind.c in Sources */,
880- E41251B628C4B1AB00E12983 /* listctrl_wx32.cpp in Sources */,
881880 E4FC77BB183E4F3F0064FB2E /* ruby_dialog.c in Sources */,
882881 E4FC77BC183E4F3F0064FB2E /* ruby_md.c in Sources */,
883882 E4FC77BD183E4F3F0064FB2E /* ruby_types.c in Sources */,
@@ -907,7 +906,6 @@
907906 E4D379A219C87C2200636D28 /* modalwindow.cpp in Sources */,
908907 E4D37E0E19CC831500636D28 /* modalwindow_osx.mm in Sources */,
909908 E4D3806619CEC7B600636D28 /* MyTextCtrl.cpp in Sources */,
910- E45B94621A170B9A008E95EB /* docview.cpp in Sources */,
911909 );
912910 runOnlyForDeploymentPostprocessing = 0;
913911 };
--- a/wxSources/MoleculeView.cpp
+++ b/wxSources/MoleculeView.cpp
@@ -234,7 +234,7 @@ MoleculeView::OnCreate(wxDocument *doc, long WXUNUSED(flags) )
234234 wxBoxSizer *sizer31 = new wxBoxSizer(wxVERTICAL);
235235 { // "Rotate bond" button and mySlider
236236 #include "../bitmaps/rotate_bond.xpm"
237- wxBitmap bmp1(rotate_bond_xpm, wxBITMAP_TYPE_XPM);
237+ wxBitmap bmp1(rotate_bond_xpm);
238238 wxBitmapButton *button1 = new wxBitmapButton(panel1, -1, bmp1, wxDefaultPosition, wxSize(21, 21), wxTOGGLEBUTTON_STYLE);
239239 sizer31->Add(button1, 0, 0, 0);
240240 button1->Disable();
@@ -257,7 +257,7 @@ MoleculeView::OnCreate(wxDocument *doc, long WXUNUSED(flags) )
257257 wxBoxSizer *sizer321 = new wxBoxSizer(wxHORIZONTAL);
258258 {
259259 #include "../bitmaps/rotate_y.xpm"
260- wxBitmap bmp2(rotate_y_xpm, wxBITMAP_TYPE_XPM);
260+ wxBitmap bmp2(rotate_y_xpm);
261261 wxBitmapButton *button2 = new wxBitmapButton(panel1, -1, bmp2, wxDefaultPosition, wxSize(21, 21), wxTOGGLEBUTTON_STYLE);
262262 sizer321->Add(button2, 0, 0, 0);
263263 button2->Disable();
@@ -273,7 +273,7 @@ MoleculeView::OnCreate(wxDocument *doc, long WXUNUSED(flags) )
273273 wxBoxSizer *sizer33 = new wxBoxSizer(wxVERTICAL);
274274 { // "Rotate bond" button and mySlider
275275 #include "../bitmaps/rotate_x.xpm"
276- wxBitmap bmp3(rotate_x_xpm, wxBITMAP_TYPE_XPM);
276+ wxBitmap bmp3(rotate_x_xpm);
277277 wxBitmapButton *button3 = new wxBitmapButton(panel1, -1, bmp3, wxDefaultPosition, wxSize(21, 21), wxTOGGLEBUTTON_STYLE);
278278 button3->Disable();
279279 sizer33->Add(button3, 0, 0, 0);
@@ -298,13 +298,13 @@ MoleculeView::OnCreate(wxDocument *doc, long WXUNUSED(flags) )
298298 sizer4->Add(frameSlider, 1, wxALL | wxEXPAND, 1);
299299
300300 #include "../bitmaps/jump_to_start.xpm"
301- wxBitmap bmp41(jump_to_start_xpm, wxBITMAP_TYPE_XPM);
301+ wxBitmap bmp41(jump_to_start_xpm);
302302 wxBitmapButton *button41 = new wxBitmapButton(frameControlPanel, myID_JumpToStartButton, bmp41, wxDefaultPosition, wxSize(16, height), wxTOGGLEBUTTON_STYLE);
303303 sizer4->Add(button41, 0, wxEXPAND);
304304 ConnectMouseDownEvents(button41, MoleculeView::OnFrameButtonAction, this);
305305
306306 #include "../bitmaps/play_backward.xpm"
307- wxBitmap bmp42(play_backward_xpm, wxBITMAP_TYPE_XPM);
307+ wxBitmap bmp42(play_backward_xpm);
308308 wxBitmapButton *button42 = new wxBitmapButton(frameControlPanel, myID_PlayBackwardButton, bmp42, wxDefaultPosition, wxSize(16, height), wxTOGGLEBUTTON_STYLE);
309309 sizer4->Add(button42, 0, wxEXPAND);
310310 ConnectMouseDownEvents(button42, MoleculeView::OnFrameButtonAction, this);
@@ -320,13 +320,13 @@ MoleculeView::OnCreate(wxDocument *doc, long WXUNUSED(flags) )
320320 }
321321
322322 #include "../bitmaps/play_forward.xpm"
323- wxBitmap bmp43(play_forward_xpm, wxBITMAP_TYPE_XPM);
323+ wxBitmap bmp43(play_forward_xpm);
324324 wxBitmapButton *button43 = new wxBitmapButton(frameControlPanel, myID_PlayForwardButton, bmp43, wxDefaultPosition, wxSize(16, height), wxTOGGLEBUTTON_STYLE);
325325 sizer4->Add(button43, 0, wxEXPAND);
326326 ConnectMouseDownEvents(button43, MoleculeView::OnFrameButtonAction, this);
327327
328328 #include "../bitmaps/jump_to_end.xpm"
329- wxBitmap bmp44(jump_to_end_xpm, wxBITMAP_TYPE_XPM);
329+ wxBitmap bmp44(jump_to_end_xpm);
330330 wxBitmapButton *button44 = new wxBitmapButton(frameControlPanel, myID_JumpToEndButton, bmp44, wxDefaultPosition, wxSize(16, height), wxTOGGLEBUTTON_STYLE);
331331 sizer4->Add(button44, 0, wxEXPAND);
332332 ConnectMouseDownEvents(button44, MoleculeView::OnFrameButtonAction, this);
--- a/wxSources/MyApp.cpp
+++ b/wxSources/MyApp.cpp
@@ -113,24 +113,26 @@ END_EVENT_TABLE()
113113 // Windows: the directory in which the application executable is located.
114114 // UNIX: ?
115115 wxString
116-MyApp::FindResourcePath()
116+MyApp::InitResourcePath(int& argc, wxChar **argv)
117117 {
118118 #if defined(__WXMAC__)
119119 CFBundleRef mainBundle = CFBundleGetMainBundle();
120120 CFURLRef ref = CFBundleCopyResourcesDirectoryURL(mainBundle);
121121 if (ref != NULL) {
122- UInt8 buffer[256];
122+ UInt8 buffer[4096];
123123 if (CFURLGetFileSystemRepresentation(ref, true, buffer, sizeof buffer)) {
124124 wxString dirname((const char *)buffer, WX_DEFAULT_CONV);
125125 CFRelease(ref);
126+ m_resourcePath = dirname;
126127 return dirname;
127128 }
128129 CFRelease(ref);
129130 }
131+ m_resourcePath = wxEmptyString;
130132 return wxEmptyString;
131133 #elif defined(__WXMSW__)
132134 wxString str;
133- wxString argv0 = wxTheApp->argv[0];
135+ wxString argv0 = argv[0];
134136 // Fix dosish path (when invoked from MSYS console, the path may be unix-like)
135137 // Note: absolute paths like /c/Molby/... (== c:\Molby\...) is not supported
136138 {
@@ -141,28 +143,40 @@ MyApp::FindResourcePath()
141143 }
142144 // Is it an absolute path?
143145 if (wxIsAbsolutePath(argv0)) {
144- return wxPathOnly(argv0);
146+ m_resourcePath = wxPathOnly(argv0);
147+ return m_resourcePath;
145148 } else {
146149 // Is it a relative path?
147150 wxString currentDir = wxGetCwd();
148151 if (currentDir.Last() != wxFILE_SEP_PATH)
149152 currentDir += wxFILE_SEP_PATH;
150153 str = currentDir + argv0;
151- if (wxFileExists(str))
152- return wxPathOnly(str);
154+ if (wxFileExists(str)) {
155+ m_resourcePath = wxPathOnly(str);
156+ return m_resourcePath;
157+ }
153158 }
154159 // Search PATH
155160 wxPathList pathList;
156161 pathList.AddEnvList(wxT("PATH"));
157162 str = pathList.FindAbsoluteValidPath(argv0);
158- if (!str.IsEmpty())
159- return wxPathOnly(str);
160- return wxEmptyString;
163+ if (!str.IsEmpty()) {
164+ m_resourcePath = wxPathOnly(str);
165+ return m_resourcePath;
166+ }
167+ m_resourcePath = wxEmptyString;
168+ return m_resourcePath;
161169 #else
162170 #error "FindResourcePath is not defined for UNIXes."
163171 #endif
164172 }
165173
174+wxString
175+MyApp::FindResourcePath()
176+{
177+ return wxGetApp().m_resourcePath;
178+}
179+
166180 MyApp::MyApp(void)
167181 {
168182 m_docManager = NULL;
@@ -211,9 +225,12 @@ bool MyApp::Initialize(int& argc, wxChar **argv)
211225 gSuppressConsole = 0;
212226
213227 // We need these parameters in FindResourcePath(), so we assign them here
214- this->argc = argc;
215- this->argv = argv;
228+ //this->argc = argc;
229+ //this->argv = argv;
216230
231+ // Initialize the internal m_resourcePath member
232+ InitResourcePath(argc, argv);
233+
217234 static const char fname[] = "startup.rb";
218235 wxString dirname = FindResourcePath();
219236
@@ -379,6 +396,7 @@ bool MyApp::OnInit(void)
379396 {
380397 extern int gRevisionNumber;
381398 static const char fname[] = "startup.rb";
399+ InitResourcePath(argc, argv);
382400 wxString dirname = FindResourcePath();
383401
384402 dirname += wxFILE_SEP_PATH;
--- a/wxSources/MyApp.h
+++ b/wxSources/MyApp.h
@@ -187,7 +187,9 @@ class MyApp: public wxApp
187187
188188 wxMenuBar *CreateMenuBar(int kind, wxMenu **out_file_history_menu = NULL, wxMenu **out_edit_menu = NULL);
189189
190- static wxString FindResourcePath();
190+ wxString InitResourcePath(int& argc, wxChar **argv);
191+
192+ static wxString FindResourcePath();
191193 static wxString DefaultSettingsPath();
192194
193195 void LoadDefaultSettings();
@@ -273,6 +275,8 @@ protected:
273275
274276 wxTopLevelWindow *m_frameToBeDestroyed; /* Used in CheckIfAllWindowsAreGone() */
275277
278+ wxString m_resourcePath;
279+
276280 #if defined(__WXMSW__)
277281 public:
278282 wxSingleInstanceChecker *m_checker;
--- a/wxSources/MyListCtrl.cpp
+++ b/wxSources/MyListCtrl.cpp
@@ -112,24 +112,60 @@ MyListCtrl::SetDataSource(MyListCtrlDataSource *source)
112112 RefreshTable();
113113 }
114114
115+int
116+MyListCtrl::GetColumnCount()
117+{
118+ return colNames.Count();
119+}
120+
121+bool
122+MyListCtrl::DeleteColumn(int col)
123+{
124+ if (col < 0 || col >= GetColumnCount())
125+ return false;
126+ colNames.RemoveAt(col);
127+ colWidths.erase(colWidths.begin() + col);
128+ colFormats.erase(colFormats.begin() + col);
129+ SetNeedsReload();
130+ return true;
131+}
132+
133+bool
134+MyListCtrl::InsertColumn(int col, const wxString &heading, int format, int width)
135+{
136+ if (col < 0 || col > GetColumnCount())
137+ return false;
138+ colNames.Insert(heading, col);
139+ colWidths.insert(colWidths.begin() + col, width);
140+ colFormats.insert(colFormats.begin() + col, format);
141+ SetNeedsReload();
142+ return true;
143+}
144+
115145 void
116-MyListCtrl::RefreshTable()
146+MyListCtrl::SetColumnWidth(int col, int width)
147+{
148+ if (col < 0 || col > GetColumnCount())
149+ return;
150+ colWidths[col] = width;
151+ SetNeedsReload();
152+}
153+
154+void
155+MyListCtrl::RefreshTable(bool refreshWindow)
117156 {
118157 if (dataSource == NULL) {
119158 nrows = ncols = 0;
120159 } else {
121160 int i;
122161 wxSize sz = header->GetSize();
123- nrows = dataSource->GetNumberOfRows(this);
124- ncols = dataSource->GetNumberOfColumns(this);
125- colWidths.resize(ncols, 10);
162+ nrows = dataSource->GetItemCount(this);
163+ ncols = GetColumnCount();
126164 pageWidth = 0;
127165 for (i = 0; i < ncols; i++) {
128- colWidths[i] = dataSource->GetColumnWidth(this, i);
129166 pageWidth += colWidths[i];
130167 }
131168 rowHeight = dataSource->GetRowHeight(this);
132- headerHeight = dataSource->GetHeaderHeight(this);
133169 // "+4" is for drawing marker during cell dragging
134170 pageHeight = rowHeight * nrows + 4;
135171 // Set the subwindow infos
@@ -140,7 +176,17 @@ MyListCtrl::RefreshTable()
140176 Fit();
141177 Layout();
142178 }
143- Refresh();
179+ needsReload = false;
180+ if (refreshWindow)
181+ Refresh();
182+}
183+
184+void
185+MyListCtrl::SetNeedsReload(bool flag)
186+{
187+ needsReload = flag;
188+ if (needsReload)
189+ Refresh();
144190 }
145191
146192 static wxBrush lightBlueBrush(wxColour(128, 128, 255));
@@ -151,6 +197,9 @@ MyListCtrl::OnPaint(wxPaintEvent &event)
151197 if (dataSource == NULL)
152198 return;
153199
200+ if (needsReload)
201+ RefreshTable(false);
202+
154203 wxPaintDC dc(scroll);
155204 scroll->DoPrepareDC(dc);
156205 int ox, oy;
@@ -183,9 +232,14 @@ MyListCtrl::OnPaint(wxPaintEvent &event)
183232 }
184233 if (y > sz.y + oy)
185234 break;
186- str = dataSource->GetCellText(this, j, i);
187- if (dataSource->GetCellAttr(this, j, i, attr)) {
188- // TODO: attribute change
235+ str = dataSource->GetItemText(this, j, i);
236+ float fg[4], bg[4];
237+ int n = dataSource->SetItemColor(this, j, i, fg, bg);
238+ if (n & 1) {
239+ // TODO: Set foreground color
240+ }
241+ if (n & 2) {
242+ // TODO: Set background color
189243 }
190244 if (IsRowSelected(j)) {
191245 if (showDragTarget) {
@@ -234,12 +288,10 @@ MyListCtrl::OnPaintHeader(wxPaintEvent &event)
234288 for (i = 0; i < ncols; i++) {
235289 x1 = x + colWidths[i];
236290 if (x1 > 0) {
237- wxString str = dataSource->GetCellText(this, -1, i);
238- if (dataSource->GetCellAttr(this, -1, i, attr)) {
239- // TODO: do attribute change
240- }
291+ wxString str = colNames[i];
241292 dc.DrawText(str, x, 0);
242293 }
294+ x = x1;
243295 }
244296 }
245297 }
@@ -256,6 +308,26 @@ MyListCtrl::PrepareSelectionChangeNotification()
256308 selectionChangeNotificationRequired = true;
257309 }
258310
311+int
312+MyListCtrl::GetItemState(int item, int stateMask)
313+{
314+ if (stateMask & wxLIST_STATE_SELECTED)
315+ return IsRowSelected(item) ? wxLIST_STATE_SELECTED : 0;
316+ else return 0;
317+}
318+
319+bool
320+MyListCtrl::SetItemState(int item, int state, int stateMask)
321+{
322+ if (stateMask & wxLIST_STATE_SELECTED) {
323+ if (state & wxLIST_STATE_SELECTED)
324+ SelectRow(item);
325+ else
326+ UnselectRow(item);
327+ }
328+ return true;
329+}
330+
259331 bool
260332 MyListCtrl::IsRowSelected(int row)
261333 {
@@ -407,7 +479,7 @@ MyListCtrl::OnMotion(wxMouseEvent &event)
407479 if (mouseMode > 0 && !scroll->HasCapture()) {
408480 // Start dragging
409481 scroll->CaptureMouse();
410- if (mouseMode != 3 && dataSource->IsDragEnabled(this, mouseRow)) {
482+ if (mouseMode != 3 && dataSource->IsDragAndDropEnabled(this, mouseRow)) {
411483 draggingRows = true;
412484 }
413485 }
@@ -435,7 +507,7 @@ MyListCtrl::OnLeftDClick(wxMouseEvent &event)
435507 }
436508 cx += colWidths[i];
437509 }
438- if (!dataSource->IsEditable(this, col, row))
510+ if (!dataSource->IsItemEditable(this, row, col))
439511 return;
440512 StartEditText(col, row);
441513 }
@@ -443,9 +515,9 @@ MyListCtrl::OnLeftDClick(wxMouseEvent &event)
443515 void
444516 MyListCtrl::OnLeftUp(wxMouseEvent &event)
445517 {
446- int x, y, ux, uy, row, i;
518+ int x, y, ux, uy, row;
447519 bool dragged = false;
448- bool selectionChanged = selectionChangeNotifiationRequired;
520+ bool selectionChanged = selectionChangeNotificationRequired;
449521 x = event.GetX();
450522 y = event.GetY();
451523 scroll->CalcUnscrolledPosition(x, y, &ux, &uy);
@@ -485,7 +557,6 @@ MyListCtrl::OnScrollWin(wxScrollWinEvent &event)
485557 wxPoint cp = scroll->ScreenToClient(wxGetMousePosition());
486558 wxSize sz = scroll->GetClientSize();
487559 wxEventType etype = event.GetEventType();
488- wxEventType etype_org = etype;
489560 int vx, vy;
490561 int step = rowHeight;
491562 scroll->CalcUnscrolledPosition(0, 0, &vx, &vy);
@@ -570,9 +641,67 @@ MyListCtrl::FindItemAtPosition(const wxPoint &pos, int *row, int *col)
570641 return (r >= 0 && i >= 0);
571642 }
572643
644+// The return rect is the client coordinate in MyListCtrl (not scroll)
645+bool
646+MyListCtrl::GetItemRectForRowAndColumn(wxRect &rect, int row, int col)
647+{
648+ int i, tx, ty, cx, cy;
649+ if (col < 0 || col >= ncols || row < 0 || row >= nrows)
650+ return false;
651+ cy = rowHeight * row;
652+ cx = 0;
653+ for (i = 0; i < col; i++) {
654+ cx += colWidths[i];
655+ }
656+ scroll->CalcScrolledPosition(cx, cy, &tx, &ty);
657+ rect.x = tx;
658+ rect.y = ty + headerHeight;
659+ rect.width = colWidths[col];
660+ rect.height = rowHeight;
661+ return true;
662+}
663+
664+
665+bool
666+MyListCtrl::EnsureVisible(int row, int col)
667+{
668+ wxRect r;
669+ if (!GetItemRectForRowAndColumn(r, row, (col == -1 ? 0 : col)))
670+ return false;
671+ r.y -= headerHeight; // Convert to client coord in scroll
672+ wxSize sz = scroll->GetClientSize();
673+ int scx = -1, scy = -1;
674+ int ux, uy;
675+ scroll->CalcUnscrolledPosition(r.x, r.y, &ux, &uy);
676+ if (col >= 0) {
677+ if (r.x < 0) {
678+ scx = floor(ux / rowHeight);
679+ } else if (r.x + r.width > sz.x) {
680+ scx = ceil((ux + r.width - sz.x) / rowHeight);
681+ if (scx < 0)
682+ scx = 0;
683+ }
684+ } // If col is negative, then do not scroll horizontally
685+ if (r.y < 0) {
686+ scy = floor(uy / rowHeight);
687+ } else if (r.y + r.height > sz.y) {
688+ scy = ceil((uy + r.height - sz.y) / rowHeight);
689+ if (scy < 0)
690+ scy = 0;
691+ }
692+ if (scx >= 0 || scy >= 0) {
693+ scroll->Scroll(scx, scy);
694+ return true;
695+ } else return false;
696+}
697+
573698 void
574699 MyListCtrl::StartEditText(int row, int col)
575700 {
701+ wxRect r;
702+ if (!GetItemRectForRowAndColumn(r, row, col))
703+ return;
704+ r.y -= headerHeight; // Convert to client coord in scroll
576705 int i, tx, ty;
577706 int cy = rowHeight * row;
578707 int cx = 0;
@@ -581,31 +710,14 @@ MyListCtrl::StartEditText(int row, int col)
581710 }
582711 scroll->CalcScrolledPosition(cx, cy, &tx, &ty);
583712 if (editText == NULL) {
584- editText = new wxTextCtrl(scroll, -1, "", wxPoint(tx - 2, ty - 2), wxSize(colWidths[col] + 4, rowHeight + 4), wxTE_PROCESS_ENTER);
713+ editText = new wxTextCtrl(scroll, -1, "", wxPoint(r.x - 2, r.y - 2), wxSize(r.width + 4, r.height + 4), wxTE_PROCESS_ENTER);
585714 editText->Bind(wxEVT_CHAR, &MyListCtrl::OnCharInText, this);
586715 } else {
587716 FinalizeEdit();
588- editText->SetPosition(wxPoint(tx - 2, ty - 2));
589- editText->SetSize(wxSize(colWidths[col] + 4, rowHeight + 4));
590- }
591- wxSize sz = scroll->GetClientSize();
592- int scx = -1, scy = -1;
593- if (tx < 0) {
594- scx = floor(cx / rowHeight);
595- } else if (tx + colWidths[col] > sz.x) {
596- scx = ceil((colWidths[col] - sz.x) / rowHeight);
597- if (scx < 0)
598- scx = 0;
599- }
600- if (ty < 0) {
601- scy = floor(cy / rowHeight);
602- } else if (ty + rowHeight > sz.y) {
603- scy = ceil((cy + rowHeight - sz.y) / rowHeight);
604- if (scy < 0)
605- scy = 0;
717+ editText->SetPosition(wxPoint(r.x - 2, r.y - 2));
718+ editText->SetSize(wxSize(r.width + 4, r.height + 4));
606719 }
607- if (scx >= 0 || scy >= 0)
608- scroll->Scroll(scx, scy);
720+ EnsureVisible(row, col);
609721 editText->Show();
610722 editText->SetFocus();
611723 editText->SelectAll();
@@ -618,6 +730,16 @@ MyListCtrl::StartEditText(int row, int col)
618730 }
619731
620732 void
733+MyListCtrl::FinalizeEdit()
734+{
735+ if (editText != NULL) {
736+ wxString sval = editText->GetValue();
737+ if (dataSource)
738+ dataSource->SetItemText(this, editRow, editColumn, sval);
739+ }
740+}
741+
742+void
621743 MyListCtrl::EndEditText(bool setValueFlag)
622744 {
623745 if (!editText)
@@ -628,6 +750,7 @@ MyListCtrl::EndEditText(bool setValueFlag)
628750 editText->Destroy();
629751 editText = NULL;
630752 }
753+
631754 void
632755 MyListCtrl::EndEditTextAndRestart(bool setValueFlag, int newRow, int newCol)
633756 {
@@ -659,7 +782,7 @@ MyListCtrl::OnCharInText(wxKeyEvent &event)
659782 else
660783 row++;
661784 }
662- } while (row >= 0 && !dataSource->IsEditable(this, row, col));
785+ } while (row >= 0 && !dataSource->IsItemEditable(this, row, col));
663786 if (row >= 0) {
664787 StartEditText(row, col);
665788 } else {
@@ -687,7 +810,7 @@ MyListCtrl::OnCharInText(wxKeyEvent &event)
687810 row = -1;
688811 }
689812 }
690- } while (row >= 0 && !dataSource->IsEditable(this, row, col));
813+ } while (row >= 0 && !dataSource->IsItemEditable(this, row, col));
691814 if (row >= 0)
692815 StartEditText(row, col);
693816 else
--- a/wxSources/MyListCtrl.h
+++ b/wxSources/MyListCtrl.h
@@ -19,6 +19,7 @@
1919 #define __MyListCtrl_h__
2020
2121 #include "wx/scrolwin.h"
22+#include "wx/listctrl.h" // some constants are included for compatibility
2223
2324 #include "wx/string.h"
2425 #include "wx/textctrl.h"
@@ -42,8 +43,26 @@ enum MyListColumnFormat {
4243 /* Data source protocol */
4344 class MyListCtrlDataSource {
4445 public:
45- virtual int GetNumberOfRows(MyListCtrl *ctrl) { return 0; }
46- virtual int GetNumberOfColumns(MyListCtrl *ctrl) { return 0; }
46+ virtual int GetItemCount(MyListCtrl *ctrl) { return 0; }
47+ virtual wxString GetItemText(MyListCtrl *ctrl, long row, long column) const { return _T(""); }
48+ virtual int SetItemText(MyListCtrl *ctrl, long row, long column, const wxString &value) { return 0; }
49+ virtual void DragSelectionToRow(MyListCtrl *ctrl, long row) {}
50+ virtual bool IsItemEditable(MyListCtrl *ctrl, long row, long column) { return false; }
51+ virtual bool IsDragAndDropEnabled(MyListCtrl *ctrl, long row = -1) { return false; }
52+ virtual void OnSelectionChanged(MyListCtrl *ctrl) {}
53+
54+ // If a popup menu is attached to the cell, then returns a positive integer, and *menu_titles should
55+ // contain a malloc()'ed array of char* pointers (that are also malloc()'ed or strdup()'ed)
56+ virtual int HasPopUpMenu(MyListCtrl *ctrl, long row, long column, char ***menu_titles) { return 0; }
57+ virtual void OnPopUpMenuSelected(MyListCtrl *ctrl, long row, long column, int selected_index) {}
58+
59+ // Return 1 if foreground color should be modified, 2 if background color should be modified, 3 if both
60+ virtual int SetItemColor(MyListCtrl *ctrl, long row, long col, float *fg, float *bg) { return 0; }
61+
62+ virtual int GetRowHeight(MyListCtrl *ctrl, long row = -1) { return 12; }
63+
64+/* virtual int GetNumberOfRows(MyListCtrl *ctrl) { return 0; }
65+// virtual int GetNumberOfColumns(MyListCtrl *ctrl) { return 0; }
4766 virtual int GetColumnWidth(MyListCtrl *ctrl, int index) { return 0; }
4867 virtual int GetRowHeight(MyListCtrl *ctrl) { return 0; }
4968 virtual int GetHeaderHeight(MyListCtrl *ctrl) { return 0; }
@@ -59,17 +78,8 @@ public:
5978 // contain a malloc()'ed array of char* pointers (that are also malloc()'ed or strdup()'ed)
6079 virtual int HasPopUpMenu(MyListCtrl *ctrl, int row, int col, char ***menu_titles) { return 0; }
6180 virtual void OnPopUpMenuSelected(MyListCtrl *ctrl, int row, int col, int selected_index) {}
62-
63- //virtual int GetItemCount(MyListCtrl *ctrl) { return 0; }
64- //virtual wxString GetItemText(MyListCtrl *ctrl, long row, long column) const { return _T(""); }
65- //virtual int SetItemText(MyListCtrl *ctrl, long row, long column, const wxString &value) { return 0; }
66- //virtual void DragSelectionToRow(MyListCtrl *ctrl, long row) {}
67- //virtual bool IsItemEditable(MyListCtrl *ctrl, long row, long column) { return false; }
68- //virtual bool IsDragAndDropEnabled(MyListCtrl *ctrl) { return false; }
69- //virtual void OnSelectionChanged(MyListCtrl *ctrl) {}
81+*/
7082
71- // Return 1 if foreground color should be modified, 2 if background color should be modified, 3 if both
72- //virtual int SetItemColor(MyListCtrl *ctrl, long row, long col, float *fg, float *bg) { return 0; }
7383 };
7484
7585 class MyListCtrl: public wxWindow {
@@ -105,9 +115,16 @@ public:
105115
106116 void SetDataSource(MyListCtrlDataSource *source);
107117
108- void RefreshTable();
118+ void SetNeedsReload(bool flag = true);
119+ void RefreshTable(bool refreshWindow = true);
109120
110121 void PrepareSelectionChangeNotification();
122+
123+ // wxListCtrl compatibility: only wxLIST_STATE_SELECTED is implemented
124+ int GetItemCount() { return (dataSource ? dataSource->GetItemCount(this) : 0); }
125+ int GetItemState(int item, int stateMask);
126+ bool SetItemState(int item, int state, int stateMask);
127+
111128 bool IsRowSelected(int row);
112129 bool SelectRow(int row);
113130 bool UnselectRow(int row);
@@ -124,6 +141,9 @@ public:
124141 // bool GetItemRectForRowAndColumn(wxRect &rect, int row, int column);
125142 bool FindItemAtPosition(const wxPoint &pos, int *col, int *row);
126143
144+ bool GetItemRectForRowAndColumn(wxRect &rect, int row, int column);
145+ bool EnsureVisible(int row, int col = -1);
146+
127147 // void SetItemTextForColumn(long item, long column, const wxString &text);
128148
129149 void StartEditText(int col, int row);
@@ -137,10 +157,13 @@ public:
137157
138158 // void OnPaintCallback(wxDC *dc);
139159
140-// bool DeleteColumn(int col);
141-// bool InsertColumn(int col, const wxString &heading, int width = -1, int format = MyLIST_FORMAT_LEFT);
142-// int GetNumberOfColumns();
143-
160+ int GetColumnCount();
161+ bool DeleteColumn(int col);
162+ bool InsertColumn(int col, const wxString &heading, int format = MyLIST_FORMAT_LEFT, int width = -1);
163+ void SetHeaderHeight(int headerHeight);
164+ int GetHeaderHeight() { return headerHeight; }
165+ void SetColumnWidth(int col, int width);
166+
144167 void OnPaintHeader(wxPaintEvent &event);
145168 void OnPaint(wxPaintEvent &event);
146169 void OnLeftDown(wxMouseEvent &event);
@@ -169,6 +192,7 @@ public:
169192
170193 bool selectionChangeNotificationRequired;
171194 bool selectionChangeNotificationEnabled;
195+ bool needsReload;
172196 int lastPopUpColumn, lastPopUpRow;
173197
174198 private:
--- a/wxSources/MyProgressIndicator.cpp
+++ b/wxSources/MyProgressIndicator.cpp
@@ -54,21 +54,21 @@ MyProgressIndicator::MyProgressIndicator(wxWindow* parent, wxWindowID id, const
5454 #include "../bitmaps/pi09.xpm"
5555 #include "../bitmaps/pi10.xpm"
5656 #include "../bitmaps/pi11.xpm"
57- sStopMiniIcons[0] = new wxBitmap(stop_mini_grey, wxBITMAP_TYPE_XPM);
58- sStopMiniIcons[1] = new wxBitmap(stop_mini, wxBITMAP_TYPE_XPM);
59- sStopMiniIcons[2] = new wxBitmap(stop_mini_dark, wxBITMAP_TYPE_XPM);
60- sProgressIndicatorIcons[0] = new wxBitmap(pi00, wxBITMAP_TYPE_XPM);
61- sProgressIndicatorIcons[1] = new wxBitmap(pi01, wxBITMAP_TYPE_XPM);
62- sProgressIndicatorIcons[2] = new wxBitmap(pi02, wxBITMAP_TYPE_XPM);
63- sProgressIndicatorIcons[3] = new wxBitmap(pi03, wxBITMAP_TYPE_XPM);
64- sProgressIndicatorIcons[4] = new wxBitmap(pi04, wxBITMAP_TYPE_XPM);
65- sProgressIndicatorIcons[5] = new wxBitmap(pi05, wxBITMAP_TYPE_XPM);
66- sProgressIndicatorIcons[6] = new wxBitmap(pi06, wxBITMAP_TYPE_XPM);
67- sProgressIndicatorIcons[7] = new wxBitmap(pi07, wxBITMAP_TYPE_XPM);
68- sProgressIndicatorIcons[8] = new wxBitmap(pi08, wxBITMAP_TYPE_XPM);
69- sProgressIndicatorIcons[9] = new wxBitmap(pi09, wxBITMAP_TYPE_XPM);
70- sProgressIndicatorIcons[10] = new wxBitmap(pi10, wxBITMAP_TYPE_XPM);
71- sProgressIndicatorIcons[11] = new wxBitmap(pi11, wxBITMAP_TYPE_XPM);
57+ sStopMiniIcons[0] = new wxBitmap(stop_mini_grey);
58+ sStopMiniIcons[1] = new wxBitmap(stop_mini);
59+ sStopMiniIcons[2] = new wxBitmap(stop_mini_dark);
60+ sProgressIndicatorIcons[0] = new wxBitmap(pi00);
61+ sProgressIndicatorIcons[1] = new wxBitmap(pi01);
62+ sProgressIndicatorIcons[2] = new wxBitmap(pi02);
63+ sProgressIndicatorIcons[3] = new wxBitmap(pi03);
64+ sProgressIndicatorIcons[4] = new wxBitmap(pi04);
65+ sProgressIndicatorIcons[5] = new wxBitmap(pi05);
66+ sProgressIndicatorIcons[6] = new wxBitmap(pi06);
67+ sProgressIndicatorIcons[7] = new wxBitmap(pi07);
68+ sProgressIndicatorIcons[8] = new wxBitmap(pi08);
69+ sProgressIndicatorIcons[9] = new wxBitmap(pi09);
70+ sProgressIndicatorIcons[10] = new wxBitmap(pi10);
71+ sProgressIndicatorIcons[11] = new wxBitmap(pi11);
7272 }
7373 }
7474
--- a/wxSources/RubyDialogFrame.cpp
+++ b/wxSources/RubyDialogFrame.cpp
@@ -810,9 +810,9 @@ RubyDialogCallback_show(RubyDialog *dref)
810810
811811 #if defined(__WXMAC__)
812812 {
813- extern void AddWindowsItemWithTitle(const char *title);
813+ //extern void AddWindowsItemWithTitle(const char *title);
814814 wxString str = ((RubyDialogFrame *)dref)->GetLabel();
815- AddWindowsItemWithTitle(str.mb_str(WX_DEFAULT_CONV));
815+ //AddWindowsItemWithTitle(str.mb_str(WX_DEFAULT_CONV));
816816 }
817817 #endif
818818 }
旧リポジトリブラウザで表示