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"
28 BEGIN_EVENT_TABLE(GlobalParameterFrame, wxMDIChildFrame)
29 EVT_CLOSE(GlobalParameterFrame::OnCloseWindow)
30 EVT_MENU(wxID_CLOSE, GlobalParameterFrame::OnClose)
31 EVT_UPDATE_UI(wxID_CLOSE, GlobalParameterFrame::OnUpdateUI)
34 GlobalParameterFrame::GlobalParameterFrame(wxMDIParentFrame *parent, const wxString& title, const wxPoint& pos, const wxSize& size, long type):
35 wxMDIChildFrame(parent, wxID_ANY, title, pos, size, type)
39 GlobalParameterFrame::~GlobalParameterFrame()
41 wxGetApp().DocManager()->FileHistoryRemoveMenu(file_history_menu);
45 GlobalParameterFrame::OnCreate()
47 /* Make a MyListCtrl view */
49 GetClientSize(&width, &height);
50 listCtrl = new MyListCtrl();
51 listCtrl->Create(this, wxID_ANY, wxPoint(0, 0), wxSize(width, height));
52 listCtrl->SetDataSource(this);
53 wxMenuBar *menu_bar = wxGetApp().CreateMenuBar(2, &file_history_menu, &edit_menu);
55 /* Associate the menu bar with the frame */
59 GlobalParameterFrame *
60 GlobalParameterFrame::CreateGlobalParameterFrame(wxMDIParentFrame *parent)
63 wxPoint origin(16, 16);
64 wxSize size(774, 300);
66 wxPoint origin(26, 40);
67 wxSize size(774, 300);
69 GlobalParameterFrame *frame = new GlobalParameterFrame(parent, _T("Global Parameters"), origin, size, wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE);
76 GlobalParameterFrame::OnCloseWindow(wxCloseEvent &event)
78 // Do not delete this window; it may be reopened later
83 GlobalParameterFrame::OnClose(wxCommandEvent &event)
85 // Why this is not automatically connected?
90 GlobalParameterFrame::OnUpdateUI(wxUpdateUIEvent& event)
92 // Why this is not automatically done??
93 int uid = event.GetId();
94 if (uid == wxID_CLOSE)
98 #pragma mark ====== MyListCtrl data source ======
101 GlobalParameterFrame::GetItemCount(MyListCtrl *ctrl)
103 return MainView_numberOfRowsInTable(NULL);
107 GlobalParameterFrame::GetItemText(MyListCtrl *ctrl, long row, long column) const
110 MainView_valueForTable(NULL, column, row, buf, sizeof buf);
111 wxString *str = new wxString(buf, wxConvUTF8);
116 GlobalParameterFrame::SetItemText(MyListCtrl *ctrl, long row, long column, const wxString &value)
118 // MainView_setValueForTable(NULL, column, row, value.mb_str(wxConvUTF8));
123 GlobalParameterFrame::DragSelectionToRow(MyListCtrl *ctrl, long row)
128 GlobalParameterFrame::IsItemEditable(MyListCtrl *ctrl, long row, long column)
131 // return MainView_isTableItemEditable(NULL, column, row);
135 GlobalParameterFrame::IsDragAndDropEnabled(MyListCtrl *ctrl)
141 GlobalParameterFrame::OnSelectionChanged(MyListCtrl *ctrl)
143 MainView_setSelectionFromTable(NULL);
147 GlobalParameterFrame::SetItemColor(MyListCtrl *ctrl, long row, long col, float *fg, float *bg)
150 int src = ParameterTableGetItemSource(gBuiltinParameters, row);
151 if (src == -2) { /* separator row */
152 bg[0] = bg[1] = bg[2] = 0.6;