5 * Created by Toshi Nagata on 08/12/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 #ifndef __RubyDialogFrame_h__
19 #define __RubyDialogFrame_h__
22 #include "wx/dialog.h"
26 #include "../MolLib/Ruby_bind/ruby_dialog.h"
27 #include "MyListCtrl.h"
29 #include "modalwindow.h"
31 /* MyLayoutPanel: an empty subclass of wxPanel exclusively used in Dialog#layout */
32 class MyLayoutPanel: public wxPanel {
34 MyLayoutPanel(): wxPanel() {}
35 MyLayoutPanel(wxWindow *parent, wxWindowID winid = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize): wxPanel(parent, winid, pos, size) {}
36 virtual ~MyLayoutPanel() {}
38 DECLARE_DYNAMIC_CLASS(MyLayoutPanel)
41 /* MyDrawingPanel: an empty subclass of wxPanel exclusively used as "view" dialog item */
42 class MyDrawingPanel: public wxPanel {
44 MyDrawingPanel(): wxPanel() {}
45 MyDrawingPanel(wxWindow *parent, wxWindowID winid = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize): wxPanel(parent, winid, pos, size) {}
46 virtual ~MyDrawingPanel() {}
48 DECLARE_DYNAMIC_CLASS(MyDrawingPanel)
51 class RubyDialogFrame: public wxModalWindow, public MyListCtrlDataSource {
57 RubyValue dval; /* The Ruby value representing this object */
59 wxPanel *contentPanel;
60 wxSizer *contentSizer;
65 wxWindow *currentDrawingItem;
68 wxWindow *lastFocusedWindow;
71 RDSize mySize; /* Previous size */
72 bool autoResizeEnabled; /* true if auto resizing is enabled */
74 /* Message bridge (with Ruby world); obj, event_type, event_id, proc val */
75 // void **messageData;
76 // int countMessageData;
78 /* On key handler (the handler is in the Ruby world) */
79 bool onKeyHandlerEnabled;
81 /* Flag to invoke one-time initialization just before showing up */
82 bool shouldInitializeBeforeShow;
84 RubyDialogFrame():wxModalWindow() {}
85 RubyDialogFrame(wxWindow* parent, wxWindowID wid, const wxString& title, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_FRAME_STYLE);
86 virtual ~RubyDialogFrame();
88 /* For internal use (discard data in messageData[]) */
89 // void DiscardMessageData();
91 void SetAutoResizeEnabled(int flag) { autoResizeEnabled = (flag != 0); }
92 bool IsAutoResizeEnabled() { return autoResizeEnabled; }
94 // int ListenToObject(void *obj, const char *objtype, const char *msg, RubyValue oval, RubyValue pval);
95 // void HandleDocumentEvent(wxCommandEvent &event);
97 void HandlePaintEvent(wxPaintEvent &event);
99 int AddDialogItem(RDItem *item);
100 RDItem *DialogItemAtIndex(int index);
101 int SearchDialogItem(RDItem *item);
102 void SetRubyObject(RubyValue val);
103 void CreateStandardButtons(const char *oktitle, const char *canceltitle);
104 int StartIntervalTimer(int millisec);
105 void StopIntervalTimer(void);
106 void OnDialogItemAction(wxCommandEvent &event);
107 void OnTextUpdated(wxCommandEvent &event);
108 void OnEnterProcessedOnText(wxCommandEvent &event);
109 void OnEscapeProcessedOnText(wxCommandEvent &event);
110 void OnKillFocusOnText(wxFocusEvent &event);
112 void OnTimerEvent(wxTimerEvent &event);
113 void OnDefaultButtonPressed(wxCommandEvent &event);
114 void OnSize(wxSizeEvent &event);
115 void OnChar(wxKeyEvent &event);
116 void OnCloseWindow(wxCloseEvent &event);
117 void OnActivate(wxActivateEvent &event);
118 void OnChildFocus(wxChildFocusEvent &event);
119 void OnCloseFromMenu(wxCommandEvent &event);
120 void OnUpdateUI(wxUpdateUIEvent& event);
122 // MyListCtrlDataSource methods
123 virtual int GetItemCount(MyListCtrl *ctrl);
124 virtual wxString GetItemText(MyListCtrl *ctrl, long row, long column) const;
125 virtual int SetItemText(MyListCtrl *ctrl, long row, long column, const wxString &value);
126 virtual void DragSelectionToRow(MyListCtrl *ctrl, long row);
127 virtual bool IsItemEditable(MyListCtrl *ctrl, long row, long column);
128 virtual bool IsDragAndDropEnabled(MyListCtrl *ctrl, long row = -1);
129 virtual void OnSelectionChanged(MyListCtrl *ctrl);
130 virtual int SetItemColor(MyListCtrl *ctrl, long row, long col, float *fg, float *bg);
131 virtual int HasPopUpMenu(MyListCtrl *ctrl, long row, long column, char ***menu_titles);
132 virtual void OnPopUpMenuSelected(MyListCtrl *ctrl, long row, long column, int selected_index);
135 DECLARE_DYNAMIC_CLASS(RubyDialogFrame)
136 DECLARE_EVENT_TABLE()
139 #endif /* __RubyDialogFrame_h__ */