5 * Created by Toshi Nagata on 08/10/24.
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 #ifndef __MoleculeView_h__
19 #define __MoleculeView_h__
21 #include "wx/docview.h"
23 #include "../MolLib/MolLib.h"
24 #include "MyListCtrl.h"
32 class MyProgressIndicator;
34 class MoleculeView: public wxView, public MyListCtrlDataSource
37 wxDocChildFrame *frame;
42 wxMenu *file_history_menu;
44 wxToggleButton *tbuttons[6];
45 wxStaticText *infotext;
46 MyProgressIndicator *progress;
47 wxPanel *frameControlPanel;
48 wxSlider *frameSlider;
49 wxTextCtrl *frameText;
51 bool isRebuildingTable;
53 MoleculeView() { canvas = (MyGLCanvas *) NULL; frame = (wxDocChildFrame *) NULL; }
54 virtual ~MoleculeView();
56 MyDocument *MolDocument() { return (MyDocument *)m_viewDocument; }
57 MyListCtrl *GetListCtrl() { return listctrl; }
58 wxToggleButton *GetToggleButtonAtIndex(int i) { return (i >= 0 && i < 6 ? tbuttons[i] : NULL); }
60 bool OnCreate(wxDocument *doc, long flags);
61 void OnDraw(wxDC *dc);
62 void OnUpdate(wxView *sender, wxObject *hint = (wxObject *) NULL);
63 bool OnClose(bool deleteWindow = true);
64 wxImage *CaptureGLCanvas(float scale = 1.0);
66 virtual void Activate (bool activate);
67 virtual wxPrintout *OnCreatePrintout();
69 void OnButtonPressed(wxCommandEvent &event);
70 void OnSliderAction(wxCommandEvent &event);
72 void OnFrameButtonAction(wxMouseEvent &event);
73 void OnFrameSliderAction(wxScrollEvent &event);
74 void OnFrameTextAction(wxCommandEvent &event);
76 void OnDocumentModified(wxCommandEvent &event);
77 void OnChar(wxKeyEvent &event);
78 void OnScriptMenuModified(wxCommandEvent& event);
79 void OnLeftDClickInListCtrl(wxMouseEvent& event);
81 void SelectButtonForMode(int mode);
82 void UpdateFrameControlValues();
83 void UpdateFrameControls();
85 void InvalidateProgressIndicator();
86 void ProceedProgressIndicator();
87 void OnStopProgressPressed(wxCommandEvent& event);
89 void SelectTable(int idx);
90 void OnSelectTable(wxCommandEvent &event);
92 void OnActivate(wxActivateEvent &event);
94 void OnMoleculeReplaced(); /* Called when Molecule is replaced within MyDocument */
96 void EnableProgressIndicator(bool flag);
98 /* MyListCtrlDataSource functions */
99 virtual int GetItemCount(MyListCtrl *ctrl);
100 virtual wxString GetItemText(MyListCtrl *ctrl, long row, long column) const;
101 virtual int SetItemText(MyListCtrl *ctrl, long row, long column, const wxString &value);
102 virtual void DragSelectionToRow(MyListCtrl *ctrl, long row);
103 virtual bool IsItemEditable(MyListCtrl *ctrl, long row, long column);
104 virtual bool IsDragAndDropEnabled(MyListCtrl *ctrl);
105 virtual void OnSelectionChanged(MyListCtrl *ctrl);
106 virtual int SetItemColor(MyListCtrl *ctrl, long row, long col, float *fg, float *bg);
109 DECLARE_DYNAMIC_CLASS(MoleculeView)
110 DECLARE_EVENT_TABLE()