2 * GlobalParameterFrame.cpp
5 * Created by Toshi Nagata on 09/11/05.
6 * Copyright 2008 Toshi Nagata. All rights reserved.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation version 2 of the License.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
18 #include "GlobalParameterFrame.h"
22 #include "wx/colour.h"
25 #include "MyListCtrl.h"
26 #include "../MolLib/Ruby_bind/Molby_extern.h"
29 BEGIN_EVENT_TABLE(GlobalParameterFrame, wxMDIChildFrame)
30 EVT_CLOSE(GlobalParameterFrame::OnCloseWindow)
31 EVT_MENU(wxID_CLOSE, GlobalParameterFrame::OnClose)
32 EVT_UPDATE_UI(wxID_CLOSE, GlobalParameterFrame::OnUpdateUI)
35 GlobalParameterFrame::GlobalParameterFrame(wxMDIParentFrame *parent, const wxString& title, const wxPoint& pos, const wxSize& size, long type):
36 wxMDIChildFrame(parent, wxID_ANY, title, pos, size, type)
40 GlobalParameterFrame::~GlobalParameterFrame()
42 wxGetApp().DocManager()->FileHistoryRemoveMenu(file_history_menu);
46 GlobalParameterFrame::OnCreate()
48 /* Make a MyListCtrl view */
50 GetClientSize(&width, &height);
51 listCtrl = new MyListCtrl();
52 listCtrl->Create(this, wxID_ANY, wxPoint(0, 0), wxSize(width, height));
53 listCtrl->SetDataSource(this);
54 wxMenuBar *menu_bar = wxGetApp().CreateMenuBar(2, &file_history_menu, &edit_menu);
56 /* Associate the menu bar with the frame */
60 GlobalParameterFrame *
61 GlobalParameterFrame::CreateGlobalParameterFrame(wxMDIParentFrame *parent)
64 wxPoint origin(16, 16);
65 wxSize size(774, 300);
67 wxPoint origin(26, 40);
68 wxSize size(774, 300);
70 GlobalParameterFrame *frame = new GlobalParameterFrame(parent, _T("Global Parameters"), origin, size, wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE);
77 GlobalParameterFrame::OnCloseWindow(wxCloseEvent &event)
79 // Do not delete this window; it may be reopened later
84 GlobalParameterFrame::OnClose(wxCommandEvent &event)
86 // Why this is not automatically connected?
91 GlobalParameterFrame::OnUpdateUI(wxUpdateUIEvent& event)
93 // Why this is not automatically done??
94 int uid = event.GetId();
95 if (uid == wxID_CLOSE)
99 #pragma mark ====== MyListCtrl data source ======
102 GlobalParameterFrame::GetItemCount(MyListCtrl *ctrl)
104 return MainView_numberOfRowsInTable(NULL);
108 GlobalParameterFrame::GetItemText(MyListCtrl *ctrl, long row, long column) const
111 MainView_valueForTable(NULL, column, row, buf, sizeof buf);
112 wxString *str = new wxString(buf, WX_DEFAULT_CONV);
117 GlobalParameterFrame::SetItemText(MyListCtrl *ctrl, long row, long column, const wxString &value)
119 // MainView_setValueForTable(NULL, column, row, value.mb_str(WX_DEFAULT_CONV));
124 GlobalParameterFrame::DragSelectionToRow(MyListCtrl *ctrl, long row)
129 GlobalParameterFrame::IsItemEditable(MyListCtrl *ctrl, long row, long column)
132 // return MainView_isTableItemEditable(NULL, column, row);
136 GlobalParameterFrame::IsDragAndDropEnabled(MyListCtrl *ctrl)
142 GlobalParameterFrame::OnSelectionChanged(MyListCtrl *ctrl)
144 MainView_setSelectionFromTable(NULL);
148 GlobalParameterFrame::SetItemColor(MyListCtrl *ctrl, long row, long col, float *fg, float *bg)
151 int src = ParameterTableGetItemSource(gBuiltinParameters, row);
152 if (src == -2) { /* separator row */
153 bg[0] = bg[1] = bg[2] = 0.6;