OSDN Git Service

Support load/save of NBO info
[molby/Molby.git] / MolLib / Ruby_bind / ruby_dialog.h
1 /*
2  *  RubyDialog.h
3  *
4  *  Created by Toshi Nagata on 08/04/13.
5  *  Copyright 2008 Toshi Nagata. All rights reserved.
6
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation version 2 of the License.
10  
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  GNU General Public License for more details.
15  
16 */
17
18 #ifndef __ruby_dialog_h__
19 #define __ruby_dialog_h__
20
21 /*  'IntGroup' is an opaque pointer used for setting/getting selection of a 'Table' dialog item.
22     We only need the following functions:
23     IntGroup *IntGroupFromValue(VALUE val);  //  Get an opaque IntGroup pointer from a Ruby value
24     VALUE ValueFromIntGroup(IntGroup *ip);   //  Create a Ruby value from an IntGroup pointer
25     void IntGroupRelease(IntGroup *ip);      //  Release an IntGroup pointer. 
26   We need to call IntGroupRelease() after we are done with the IntGroup pointer. Note that
27   we call it after calling ValueFromIntGroup(ip) (because we are 'done' with ip).
28 */
29
30 #include "IntGroup.h"
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35         
36 /*  Style of the dialog frame  */
37 enum {
38         rd_Resizable = 1,
39         rd_HasCloseBox = 2,
40 };
41
42 #ifndef RubyValue_is_Defined
43 #define RubyValue_is_Defined
44 typedef void *RubyValue;
45 #define RubyNil (RubyValue)4
46 #define RubyFalse (RubyValue)0
47 #endif
48
49 #ifndef STUB
50 #define STUB extern
51 #endif
52
53 extern void Ruby_showError(int status);
54
55 /*  True if y-coordinate grows from bottom to top (like Cocoa)  */
56 extern int gRubyDialogIsFlipped;
57         
58 /*  Opaque structures (actually they are used only as pointers)  */
59 typedef struct RubyDialog RubyDialog;
60 typedef struct RDItem RDItem;
61 typedef struct RDDeviceContect RDDeviceContext;
62 typedef struct RDBitmap RDBitmap;
63
64 /*  Non-opaque structures  */
65 typedef struct RDPoint { float x, y; } RDPoint;
66 typedef struct RDSize  { float width, height; } RDSize;
67 typedef struct RDRect  { RDPoint origin; RDSize size; } RDRect;
68
69 extern const RDPoint gZeroPoint;
70 extern const RDSize gZeroSize;
71 extern const RDRect gZeroRect;
72         
73 /*  Utility function  */
74 extern int RubyDialog_validateItemContent(RubyValue self, RDItem *ip, const char *s);
75 extern int RubyDialog_doItemAction(RubyValue self, RDItem *ip, int options);
76 extern void RubyDialog_doTimerAction(RubyValue self);
77 extern void RubyDialog_doKeyAction(RubyValue self, int keyCode);
78 extern int RubyDialog_getFlexFlags(RubyValue self, RDItem *ip);
79 extern void RubyDialog_doCloseWindow(RubyValue self, int isModal);
80 extern void RubyDialog_doPaintAction(RubyValue self, RDItem *ip);
81
82 extern int RubyDialog_GetTableItemCount(RubyValue self, RDItem *ip);
83 extern void RubyDialog_GetTableItemText(RubyValue self, RDItem *ip, int row, int column, char *buf, int blen);
84 extern int RubyDialog_SetTableItemText(RubyValue self, RDItem *ip, int row, int column, const char *str);
85 extern void RubyDialog_DragTableSelectionToRow(RubyValue self, RDItem *ip, int row);
86 extern int RubyDialog_IsTableItemEditable(RubyValue self, RDItem *ip, int row, int column);
87 extern int RubyDialog_IsTableDragAndDropEnabled(RubyValue self, RDItem *ip, int row);
88 extern void RubyDialog_OnTableSelectionChanged(RubyValue self, RDItem *ip);
89 extern int RubyDialog_SetTableItemColor(RubyValue self, RDItem *ip, int row, int column, float *fg, float *bg);
90 extern int RubyDialog_HasPopUpMenu(RubyValue self, RDItem *ip, int row, int column, char ***menu_titles);
91 extern void RubyDialog_OnPopUpMenuSelected(RubyValue self, RDItem *ip, int row, int column, int selected_index);
92
93 extern void RubyDialogInitClass(void);
94
95 /*  Stub entries  */
96 STUB RubyValue RubyDialogCallback_parentModule(void);   
97 STUB RubyDialog *RubyDialogCallback_new(int style);
98 STUB void RubyDialogCallback_release(RubyDialog *dref);
99 STUB void RubyDialogCallback_setRubyObject(RubyDialog *dref, RubyValue val);
100 STUB void RubyDialogCallback_setWindowTitle(RubyDialog *dref, const char *title);
101 STUB int RubyDialogCallback_runModal(RubyDialog *dref);
102 STUB int RubyDialogCallback_isModal(RubyDialog *dref);
103 STUB void RubyDialogCallback_endModal(RubyDialog *dref, int status);
104 STUB void RubyDialogCallback_destroy(RubyDialog *dref);
105 STUB void RubyDialogCallback_close(RubyDialog *dref);
106 STUB void RubyDialogCallback_show(RubyDialog *dref);
107 STUB void RubyDialogCallback_hide(RubyDialog *dref);
108 STUB int RubyDialogCallback_isActive(RubyDialog *dref); 
109         
110 STUB int RubyDialogCallback_startIntervalTimer(RubyDialog *dref, float interval);
111 STUB void RubyDialogCallback_stopIntervalTimer(RubyDialog *dref);
112 STUB void RubyDialogCallback_enableOnKeyHandler(RubyDialog *dref, int flag);
113
114 STUB RDSize RubyDialogCallback_windowMinSize(RubyDialog *dref);
115 STUB void RubyDialogCallback_setWindowMinSize(RubyDialog *dref, RDSize size);
116 STUB RDSize RubyDialogCallback_windowSize(RubyDialog *dref);
117 STUB void RubyDialogCallback_setWindowSize(RubyDialog *dref, RDSize size);
118
119 STUB void RubyDialogCallback_setAutoResizeEnabled(RubyDialog *dref, int flag);
120 STUB int RubyDialogCallback_isAutoResizeEnabled(RubyDialog *dref);
121
122 //STUB int RubyDialogCallback_Listen(RubyDialog *dref, void *obj, const char *objtype, const char *msg, RubyValue oval, RubyValue pval);
123
124 STUB void RubyDialogCallback_createStandardButtons(RubyDialog *dref, const char *oktitle, const char *canceltitle);
125 STUB RDItem *RubyDialogCallback_createItem(RubyDialog *dref, const char *type, const char *title, RDRect frame);
126 STUB RDItem *RubyDialogCallback_dialogItemAtIndex(RubyDialog *dref, int idx);
127 //STUB RDItem *RubyDialogCallback_itemWithTag(RubyDialog *dref, int tag);
128 STUB int RubyDialogCallback_indexOfItem(RubyDialog *dref, RDItem *item);
129 //STUB int RubyDialogCallback_tagOfItem(RDItem *item);
130 STUB void RubyDialogCallback_moveItemUnderView(RDItem *item, RDItem *superView, RDPoint origin);
131 STUB RDItem *RubyDialogCallback_superview(RDItem *item);
132 STUB char *RubyDialogCallback_titleOfItem(RDItem *item);
133 STUB RDRect RubyDialogCallback_frameOfItem(RDItem *item);
134 STUB void RubyDialogCallback_setFrameOfItem(RDItem *item, RDRect rect);
135 STUB void RubyDialogCallback_setStringToItem(RDItem *item, const char *s);
136 STUB void RubyDialogCallback_getStringFromItem(RDItem *item, char *buf, int bufsize);
137 STUB char *RubyDialogCallback_getStringPtrFromItem(RDItem *item);
138 STUB void RubyDialogCallback_setTitleToItem(RDItem *item, const char *s);
139 STUB void RubyDialogCallback_setEnabledForItem(RDItem *item, int flag);
140 STUB int RubyDialogCallback_isItemEnabled(RDItem *item);
141 STUB void RubyDialogCallback_setEditableForItem(RDItem *item, int flag);
142 STUB int RubyDialogCallback_isItemEditable(RDItem *item);
143 STUB void RubyDialogCallback_setStateForItem(RDItem *item, int state);
144 STUB int RubyDialogCallback_getStateForItem(RDItem *item);
145 STUB void RubyDialogCallback_setHiddenForItem(RDItem *item, int flag);
146 STUB int RubyDialogCallback_isItemHidden(RDItem *item);
147 STUB void RubyDialogCallback_setNeedsDisplay(RDItem *item, int flag);
148 STUB void RubyDialogCallback_setNeedsDisplayInRect(RDItem *item, RDRect rect, int eraseBackground);
149 STUB void RubyDialogCallback_setFontForItem(RDItem *item, int size, int family, int style, int weight);
150 STUB int RubyDialogCallback_getFontForItem(RDItem *item, int *size, int *family, int *style, int *weight);
151 STUB void RubyDialogCallback_setForegroundColorForItem(RDItem *item, const double *col);
152 STUB void RubyDialogCallback_setBackgroundColorForItem(RDItem *item, const double *col);
153 STUB void RubyDialogCallback_getForegroundColorForItem(RDItem *item, double *col);
154 STUB void RubyDialogCallback_getBackgroundColorForItem(RDItem *item, double *col);
155 STUB int RubyDialogCallback_appendString(RDItem *item, const char *str);
156
157 STUB int RubyDialogCallback_countSubItems(RDItem *item);
158 STUB int RubyDialogCallback_appendSubItem(RDItem *item, const char *s);
159 STUB int RubyDialogCallback_insertSubItem(RDItem *item, const char *s, int pos);
160 STUB int RubyDialogCallback_deleteSubItem(RDItem *item, int pos);
161 STUB char *RubyDialogCallback_titleOfSubItem(RDItem *item, int pos);
162 STUB void RubyDialogCallback_setSelectedSubItem(RDItem *item, int pos); 
163 STUB int RubyDialogCallback_selectedSubItem(RDItem *item);
164         
165 STUB RDSize RubyDialogCallback_sizeOfString(RDItem *item, const char *s);
166 STUB RDSize RubyDialogCallback_resizeToBest(RDItem *item);
167
168 STUB char RubyDialogCallback_insertTableColumn(RDItem *item, int col, const char *heading, int format, int width);
169 STUB char RubyDialogCallback_deleteTableColumn(RDItem *item, int col);
170 STUB int RubyDialogCallback_countTableColumn(RDItem *item);
171 STUB char RubyDialogCallback_isTableRowSelected(RDItem *item, int row);
172 STUB IntGroup *RubyDialogCallback_selectedTableRows(RDItem *item);
173 STUB char RubyDialogCallback_setSelectedTableRows(RDItem *item, IntGroup *ig, int extend);
174 // STUB char RubyDialogCallback_setTableRowSelected(RDItem *item, int row, int flag);
175 STUB void RubyDialogCallback_refreshTable(RDItem *item);
176
177 STUB int RubyDialogCallback_savePanel(const char *title, const char *dirname, const char *wildcard, char *buf, int bufsize);
178 STUB int RubyDialogCallback_openPanel(const char *title, const char *dirname, const char *wildcard, char ***array, int for_directories, int multiple_selection);
179
180 STUB RDDeviceContext *RubyDialogCallback_getDeviceContextForRubyDialog(RubyDialog *dref);
181 STUB void RubyDialogCallback_clear(RDDeviceContext *dc);
182 STUB void RubyDialogCallback_drawEllipse(RDDeviceContext *dc, float x, float y, float r1, float r2);
183 STUB void RubyDialogCallback_drawLine(RDDeviceContext *dc, int ncoords, float *coords);
184 STUB void RubyDialogCallback_drawRectangle(RDDeviceContext *dc, float x, float y, float width, float height, float round);
185 STUB void RubyDialogCallback_drawText(RDDeviceContext *dc, const char *s, float x, float y);
186 STUB void RubyDialogCallback_setFont(RDDeviceContext *dc, void **args);
187 STUB void RubyDialogCallback_setPen(RDDeviceContext *dc, void **args);
188 STUB void RubyDialogCallback_setBrush(RDDeviceContext *dc, void **args);
189
190 STUB RDBitmap *RubyDialogCallback_createBitmap(int width, int height, int depth);
191 STUB void RubyDialogCallback_releaseBitmap(RDBitmap *bitmap);
192 STUB RDDeviceContext *RubyDialogCallback_getDeviceContextForBitmap(RDBitmap *bitmap);
193 STUB int RubyDialogCallback_executeWithFocusOnBitmap(RDBitmap *bitmap, void (*callback)(void *), void *ptr);
194 STUB int RubyDialogCallback_saveBitmapToFile(RDBitmap *bitmap, const char *fname);
195         
196 #ifdef __cplusplus
197 }
198 #endif
199                 
200 #endif /* __ruby_dialog_h__ */