//Metoda usuwa obiekt z kontenera void CDrawableManager::DestroyDrawable(IDrawable* drawable) { if (drawable != NULL) { UnregisterDrawable(drawable); delete drawable; } else fprintf(stderr, "warning: CDrawableManager::DestroyDrawable: tried to destroy null drawable\n"); }
//Metoda rejestruje obiekt void CDrawableManager::RegisterDrawable(IDrawable* drawable, int z_index) { if (!IsCorrectZIndex(z_index)) return; if (drawable == NULL) return; if (drawable->m_layer_index >= 0) UnregisterDrawable(drawable); m_layers[z_index].push_back(drawable); drawable->m_layer_index = z_index; drawable->m_layer_vector_index = (int)(m_layers[z_index].size()-1); }
/*********************************************************************** * Event Handler to detect the destruction of a client window ***********************************************************************/ static void SubstructureNotifyHandler ( Widget widget, XtPointer client_data, XEvent* event, Boolean* cont) { PluginInstance* This = (PluginInstance*) client_data; #ifdef PLUGIN_TRACE fprintf (stderr, "%s\n", "SubstructureNotifyHandler"); #endif if (event->type == DestroyNotify) { int i; #ifdef PLUGIN_TRACE fprintf (stderr, "%s\n", "DestroyNotify"); #endif for (i = 0; i < This->nclient_windows; i++) if (This->client_windows[i].win == event->xdestroywindow.window) { This->nclient_windows--; if (This->nclient_windows > 0) { /* remove this window from the list */ for (; i < This->nclient_windows; i++) This->client_windows[i] = This->client_windows[i + 1]; } else { /* no more client windows! */ /* get back to user to restart the application */ RxpSetStatusWidget(This, WAITING); } ResetWMColormap(This, event->xdestroywindow.window); UnregisterDrawable(event->xdestroywindow.window, This->plugin_widget); break; } } }