OSDN Git Service

A couple of bugfix in the Document. The version number is set to 1.0b1.
[molby/Molby.git] / wxSources / MoleculeView.h
1 /*
2  *  MoleculeView.h
3  *  Molby
4  *
5  *  Created by Toshi Nagata on 08/10/24.
6  *  Copyright 2008 Toshi Nagata. All rights reserved.
7  *
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.
11  
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.
16  */
17
18 #ifndef __MoleculeView_h__
19 #define __MoleculeView_h__
20
21 #include "wx/docview.h"
22
23 #include "../MolLib/MolLib.h"
24 #include "MyListCtrl.h"
25
26 class MyDocument;
27 class MyGLCanvas;
28 class wxMenu;
29 class wxToggleButton;
30 class wxStaticText;
31 class wxChoice;
32 class MyProgressIndicator;
33
34 class MoleculeView: public wxView, public MyListCtrlDataSource
35 {
36 public:
37     wxDocChildFrame *frame;
38     MyGLCanvas *canvas;
39     MainView *mview;
40         wxChoice *listmenu;
41         MyListCtrl *listctrl;
42         wxMenu *file_history_menu;
43         wxMenu *edit_menu;
44         wxToggleButton *tbuttons[6];
45         wxStaticText *infotext;
46         MyProgressIndicator *progress;
47         wxPanel *frameControlPanel;
48         wxSlider *frameSlider;
49         wxTextCtrl *frameText;
50
51         bool isRebuildingTable;
52
53     MoleculeView() { canvas = (MyGLCanvas *) NULL; frame = (wxDocChildFrame *) NULL; }
54     virtual ~MoleculeView();
55
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); }
59
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);
65
66         virtual void Activate (bool activate);
67         virtual wxPrintout *OnCreatePrintout();
68
69         void OnButtonPressed(wxCommandEvent &event);
70         void OnSliderAction(wxCommandEvent &event);
71
72         void OnFrameButtonAction(wxMouseEvent &event);
73         void OnFrameSliderAction(wxScrollEvent &event);
74         void OnFrameTextAction(wxCommandEvent &event);
75
76         void OnDocumentModified(wxCommandEvent &event);
77         void OnChar(wxKeyEvent &event);
78         void OnScriptMenuModified(wxCommandEvent& event);
79         void OnLeftDClickInListCtrl(wxMouseEvent& event);
80
81         void SelectButtonForMode(int mode);
82         void UpdateFrameControlValues();
83         void UpdateFrameControls();
84
85         void InvalidateProgressIndicator();
86         void ProceedProgressIndicator();
87         void OnStopProgressPressed(wxCommandEvent& event);
88
89         void SelectTable(int idx);
90         void OnSelectTable(wxCommandEvent &event);
91
92         void OnActivate(wxActivateEvent &event);
93         
94         void OnMoleculeReplaced();  /*  Called when Molecule is replaced within MyDocument  */
95
96         void EnableProgressIndicator(bool flag);
97
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);
107
108 private:
109     DECLARE_DYNAMIC_CLASS(MoleculeView)
110     DECLARE_EVENT_TABLE()
111 };
112
113 #endif