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"
25 #include "MyToggleButton.h"
32 class MyProgressIndicator;
34 class MoleculeView: public wxView, public MyListCtrlDataSource
37 wxDocChildFrame *frame;
42 wxMenu *file_history_menu;
44 MyToggleButton *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 MyToggleButton *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, int bg_color = -1, int width = 0, int height = 0);
65 int DoExportGraphic(wxString& fname, float scale, int bg_color, int width, int height);
67 virtual void Activate (bool activate);
68 virtual wxPrintout *OnCreatePrintout();
70 void OnButtonPressed(wxCommandEvent &event);
71 void OnSliderAction(wxCommandEvent &event);
73 void OnFrameButtonAction(wxMouseEvent &event);
74 void OnFrameSliderAction(wxScrollEvent &event);
75 void OnFrameTextAction(wxCommandEvent &event);
77 void OnDocumentModified(wxCommandEvent &event);
78 void OnChar(wxKeyEvent &event);
79 void OnScriptMenuModified(wxCommandEvent& event);
80 void OnLeftDClickInListCtrl(wxMouseEvent& event);
82 void SelectButtonForMode(int mode);
83 void UpdateFrameControlValues();
84 void UpdateFrameControls();
86 void InvalidateProgressIndicator();
87 void ProceedProgressIndicator();
88 void OnStopProgressPressed(wxCommandEvent& event);
90 void SelectTable(int idx);
91 void OnSelectTable(wxCommandEvent &event);
93 void OnActivate(wxActivateEvent &event);
95 void OnMoleculeReplaced(); /* Called when Molecule is replaced within MyDocument */
97 void EnableProgressIndicator(bool flag);
99 /* MyListCtrlDataSource functions */
100 virtual int GetItemCount(MyListCtrl *ctrl);
101 virtual wxString GetItemText(MyListCtrl *ctrl, long row, long column) const;
102 virtual int SetItemText(MyListCtrl *ctrl, long row, long column, const wxString &value);
103 virtual void DragSelectionToRow(MyListCtrl *ctrl, long row);
104 virtual bool IsItemEditable(MyListCtrl *ctrl, long row, long column);
105 virtual bool IsDragAndDropEnabled(MyListCtrl *ctrl, long row);
106 virtual void OnSelectionChanged(MyListCtrl *ctrl);
107 virtual int SetItemColor(MyListCtrl *ctrl, long row, long col, float *fg, float *bg);
108 virtual bool IsRowSelectable(MyListCtrl *ctrl, long row);
111 DECLARE_DYNAMIC_CLASS(MoleculeView)
112 DECLARE_EVENT_TABLE()