if (type == sTableSymbol) {
IntGroup *ig = IntGroupFromValue(val);
int row, count;
- count = RubyDialog_GetTableItemCount((RubyValue)self, (RDItem *)view);
+ count = RubyDialog_GetTableItemCount((RubyValue)dialog_val, (RDItem *)view);
for (row = 0; row < count; row++) {
int flag = (IntGroupLookup(ig, row, NULL) != 0);
RubyDialogCallback_setTableRowSelected((RDItem *)view, row, flag);
if (type == sTableSymbol) {
IntGroup *ig = IntGroupNew();
int row, count;
- count = RubyDialog_GetTableItemCount((RubyValue)self, (RDItem *)view);
+ count = RubyDialog_GetTableItemCount((RubyValue)dialog_val, (RDItem *)view);
for (row = 0; row < count; row++) {
if (RubyDialogCallback_isTableRowSelected((RDItem *)view, row))
IntGroupAdd(ig, row, 1);
*
* Hide the modeless dialog. This is to be used with Dialog#show in pairs.
* If the dialog is registered in the ruby_dialog_list global variable, it becomes unregistered.
- * Mixing Dialog#hide and Dialog#run will lead to unpredictable results, including crash. The
+ * Mixing Dialog#hide and Dialog#run will lead to unpredictable results, including crash.
*/
static VALUE
s_RubyDialog_Hide(VALUE self)
free(ditems);
for (i = 0; i < countMessageData; i++) {
if (messageData[i * 5] != NULL) {
- ((wxEvtHandler *)messageData[i * 5])->Disconnect((int)messageData[i * 5 + 1], (wxEventType)messageData[i * 5 + 2], wxCommandEventHandler(RubyDialogFrame::HandleDocumentEvent));
+ wxEventType eventType = (wxEventType)messageData[i * 5 + 2];
+ wxEvtHandler *handler = NULL;
+ if (eventType == MyDocumentEvent)
+ handler = MyDocumentFromMolecule((Molecule *)messageData[i * 5]);
+ if (handler != NULL) {
+ handler->Disconnect((int)messageData[i * 5 + 1], eventType, wxCommandEventHandler(RubyDialogFrame::HandleDocumentEvent), NULL, this);
+ }
}
- }
+ }
}
int
if (pval == NULL || pval == RubyNil) {
/* Remove the registration */
for (i = 0; i < countMessageData; i++) {
- if (messageData[i * 5] == (void *)handler &&
+ if (messageData[i * 5] == obj &&
messageData[i * 5 + 1] == (void *)eventId &&
messageData[i * 5 + 2] == (void *)eventType) {
- handler->Disconnect(eventId, eventType, wxCommandEventHandler(RubyDialogFrame::HandleDocumentEvent));
+ handler->Disconnect(eventId, eventType, wxCommandEventHandler(RubyDialogFrame::HandleDocumentEvent), NULL, this);
+ if (eventType == MyDocumentEvent)
+ MoleculeRelease((Molecule *)obj);
break;
}
}
/* Check the duplicate */
j = countMessageData; /* The position to store info if it is new */
for (i = 0; i < countMessageData; i++) {
- if (messageData[i * 5] == (void *)handler &&
+ if (messageData[i * 5] == obj &&
messageData[i * 5 + 1] == (void *)eventId &&
messageData[i * 5 + 2] == (void *)eventType) {
/* Just replace the arguments */
/* Create a new entry */
InsertArray(&messageData, &countMessageData, sizeof(void *) * 5, i, 1, NULL);
}
- messageData[j * 5] = (void *)handler;
+ messageData[j * 5] = obj;
messageData[j * 5 + 1] = (void *)eventId;
messageData[j * 5 + 2] = (void *)eventType;
messageData[j * 5 + 3] = (void *)oval;
messageData[j * 5 + 4] = (void *)pval;
handler->Connect(eventId, eventType, wxCommandEventHandler(RubyDialogFrame::HandleDocumentEvent), NULL, this);
+ if (eventType == MyDocumentEvent)
+ MoleculeRetain((Molecule *)obj);
i = j;
}
return i;
int eventId = event.GetId();
int eventType = event.GetEventType();
wxObject *eventObject = event.GetEventObject();
-
+ void *obj;
+
+ if (eventType == MyDocumentEvent) {
+ if (wxDynamicCast(eventObject, MyDocument) != NULL) {
+ obj = ((MyDocument *)eventObject)->GetMolecule();
+ } else return;
+ } else return;
+
/* Look up the message table */
for (i = 0; i < countMessageData; i++) {
- if (messageData[i * 5] == (void *)eventObject &&
+ if (messageData[i * 5] == obj &&
messageData[i * 5 + 1] == (void *)eventId &&
messageData[i * 5 + 2] == (void *)eventType) {
int status;
RubyValue oval = (RubyValue)messageData[i * 5 + 3];
RubyValue pval = (RubyValue)messageData[i * 5 + 4];
Ruby_funcall2_protect_extern(pval, g_RubyID_call, 1, &oval, &status);
-/* if (status != 0) {
- Molby_showError(status);
- } */
}
}
event.Skip();
void
RubyDialogCallback_show(RubyDialog *dref)
{
+ if (((RubyDialogFrame *)dref)->myTimer != NULL)
+ ((RubyDialogFrame *)dref)->StartIntervalTimer(-1);
((RubyDialogFrame *)dref)->Show(true);
((RubyDialogFrame *)dref)->Raise();
}