00001
00012 #include "../../include/wxIFM/manager.h"
00013 #include "../../include/wxIFM/plugin.h"
00014 #include "../../include/wxIFM/definterface.h"
00015 #include "../../include/wxIFM/defplugin.h"
00016
00017 #include <wx/statusbr.h>
00018 #include <wx/dc.h>
00019
00020 DEFINE_IFM_DATA_KEY(IFM_FLOATING_DATA_KEY)
00021
00022 DEFINE_IFM_CHILD_TYPE(IFM_CHILD_GENERIC)
00023 DEFINE_IFM_CHILD_TYPE(IFM_CHILD_TOOLBAR)
00024
00025 #if IFM_USE_WX_RTTI
00026 IMPLEMENT_DYNAMIC_CLASS(wxIFMChildDataBase, wxObject);
00027 #endif
00028
00029 wxIFMComponentDataKeyType GetNewDataKey()
00030 {
00031 static int next;
00032
00033 return next++;
00034 }
00035
00036 int GetNewComponentType()
00037 {
00038 static int next = 1;
00039
00040 return next++;
00041 }
00042
00043 int GetNewChildType()
00044 {
00045 static int next = 1;
00046
00047 return next++;
00048 }
00049
00050
00051
00052
00053 wxInterfaceManager::wxInterfaceManager(wxWindow *parent, wxWindow *content)
00054 : m_initialized(false),
00055 m_flags(IFM_DEFAULT_FLAGS),
00056 m_parent(parent),
00057 m_content(content),
00058 m_capturedComponent(NULL),
00059 m_capturedType(IFM_COMPONENT_UNDEFINED),
00060 #if IFM_CANFLOAT
00061 m_floatingCapture(NULL),
00062 #endif
00063 m_useUpdateRect(false),
00064 m_statusbarPane(IFM_DISABLE_STATUS_MESSAGES),
00065 m_statusMessageDisplayed(false)
00066 {
00067 wxASSERT_MSG(m_parent, wxT("An interface cannot have a NULL parent"));
00068 }
00069
00070 wxInterfaceManager::~wxInterfaceManager()
00071 {
00072
00073 }
00074
00075 wxWindow *wxInterfaceManager::GetParent() const
00076 {
00077 return m_parent;
00078 }
00079
00080 const wxRect &wxInterfaceManager::GetInterfaceRect() const
00081 {
00082 return m_updateRect;
00083 }
00084
00085 void wxInterfaceManager::SetInterfaceRect(const wxRect &rect)
00086 {
00087 m_useUpdateRect = true;
00088 m_updateRect = rect;
00089 }
00090
00091 void wxInterfaceManager::ResetInterfaceRect()
00092 {
00093 m_useUpdateRect = false;
00094 }
00095
00096 wxWindow *wxInterfaceManager::GetContentWindow() const
00097 {
00098 return m_content;
00099 }
00100
00101 void wxInterfaceManager::SetContentWindow(wxWindow *content)
00102 {
00103 m_content = content;
00104 }
00105
00106 void wxInterfaceManager::SetFlags(int flags)
00107 {
00108 m_flags = flags;
00109 }
00110
00111 int wxInterfaceManager::GetFlags() const
00112 {
00113 return m_flags;
00114 }
00115
00116 void wxInterfaceManager::HideChild(wxWindow *child, bool update)
00117 {
00118 ShowChild(child, false, update);
00119 }
00120
00121 wxIFMInterfacePluginBase *wxInterfaceManager::GetActiveIP() const
00122 {
00123 return m_interfacePlugins[m_activeInterface];
00124 }
00125
00126 bool wxInterfaceManager::IsInputCaptured() const
00127 {
00128 return m_capturedComponent != NULL;
00129 }
00130
00131 wxIFMComponent *wxInterfaceManager::GetCapturedComponent() const
00132 {
00133 return m_capturedComponent;
00134 }
00135
00136 bool wxInterfaceManager::Initialize(bool defaultPlugins, int flags)
00137 {
00138 m_flags = flags;
00139
00140
00141 m_parent->PushEventHandler(this);
00142
00143 if( defaultPlugins )
00144 {
00145
00146 wxIFMInterfacePluginBase *plugin = new wxIFMDefaultInterfacePlugin();
00147 if( AddInterfacePlugin(plugin) == -1 )
00148 {
00149 delete plugin;
00150 return (m_initialized = false);
00151 }
00152 }
00153
00154 return (m_initialized = true);
00155 }
00156
00157 void wxInterfaceManager::Shutdown()
00158 {
00159 wxASSERT_MSG(m_initialized, wxT("Interface not initialized"));
00160
00161 RemoveAllInterfacePlugins();
00162 m_parent->RemoveEventHandler(this);
00163 }
00164
00165 bool wxInterfaceManager::AddChild(wxIFMChildDataBase *data, bool update)
00166 {
00167 wxASSERT_MSG(m_initialized, wxT("Interface not initialized"));
00168 wxASSERT_MSG(data, wxT("Child data cannot be NULL."));
00169
00170 wxASSERT_MSG(data->m_child, wxT("Adding a NULL child?"));
00171 wxASSERT_MSG(data->m_type != IFM_CHILDTYPE_UNDEFINED, wxT("Must specify a child type"));
00172
00173
00174 wxIFMAddChildEvent event(data);
00175
00176
00177 GetActiveIP()->ProcessPluginEvent(event);
00178 if( !event.GetSuccess() )
00179 return false;
00180
00181
00182 if( update )
00183 Update();
00184
00185 return true;
00186 }
00187
00188 void wxInterfaceManager::ShowChild(wxWindow *child, bool show, bool update)
00189 {
00190
00191 wxIFMShowChildEvent event(child, show, update);
00192 GetActiveIP()->ProcessPluginEvent(event);
00193 }
00194
00195 bool wxInterfaceManager::IsChildVisible(wxWindow *child)
00196 {
00197 wxIFMQueryChildEvent event(child);
00198 if(GetActiveIP()->ProcessPluginEvent(event))
00199 return event.IsVisible();
00200
00201 return false;
00202 }
00203
00204 void wxInterfaceManager::SetChildSize(wxWindow *child, const wxSize &desired, const wxSize &min,
00205 const wxSize &max, bool update)
00206 {
00207
00208 wxIFMSetChildSizeEvent event(child, desired, min, max, update);
00209 GetActiveIP()->ProcessPluginEvent(event);
00210 }
00211
00212 int wxInterfaceManager::AddInterfacePlugin(wxIFMInterfacePluginBase *plugin, bool select)
00213 {
00214
00215
00216 {
00217 wxIFMDefaultPlugin *_plugin = new wxIFMDefaultPlugin(plugin);
00218 plugin->SetNextHandler(_plugin);
00219 _plugin->SetPreviousHandler(plugin);
00220 }
00221
00222 if( !plugin->Initialize(this) )
00223 return -1;
00224
00225 m_interfacePlugins.push_back(plugin);
00226
00227 int index = m_interfacePlugins.size() - 1;
00228
00229 if( select )
00230 SetActiveInterface(m_interfacePlugins.size() - 1);
00231
00232 return index;
00233 }
00234
00235 void wxInterfaceManager::SetActiveInterface(int plugin)
00236 {
00237 for( int i = 0, count = m_interfacePlugins.GetCount(); i < count; ++i )
00238
00239
00240 {
00241 if( i == plugin )
00242
00243 m_interfacePlugins[i]->Enable();
00244
00245 else
00246 m_interfacePlugins[i]->Disable();
00247
00248 }
00249
00250 m_activeInterface = plugin;
00251 }
00252
00253 void wxInterfaceManager::RemoveInterfacePlugin(int interface_index)
00254 {
00255 m_interfacePlugins[interface_index]->Shutdown();
00256
00257
00258 wxIFMInterfacePluginBase *plugin = m_interfacePlugins[interface_index];
00259 #if IFM_USE_WX_RTTI
00260 wxIFMDefaultPlugin *_plugin = wxDynamicCast(plugin->GetNextHandler(), wxIFMDefaultPlugin);
00261 #else
00262 wxIFMDefaultPlugin *_plugin = dynamic_cast<wxIFMDefaultPlugin*>(plugin->GetNextHandler());
00263 #endif
00264
00265 delete _plugin;
00266 delete plugin;
00267
00268 m_interfacePlugins.erase(m_interfacePlugins.begin() + interface_index);
00269 }
00270
00271 void wxInterfaceManager::RemoveAllInterfacePlugins()
00272 {
00273 while( m_interfacePlugins.size() > 0 )
00274 RemoveInterfacePlugin(0);
00275 }
00276
00277 bool wxInterfaceManager::AddExtensionPlugin(wxIFMExtensionPluginBase *plugin)
00278 {
00279 return GetActiveIP()->PushExtensionPlugin(plugin);
00280 }
00281
00282 void wxInterfaceManager::RemoveExtensionPlugin()
00283 {
00284 GetActiveIP()->PopExtensionPlugin();
00285 }
00286
00287 void wxInterfaceManager::RemoveAllExtensionPlugins()
00288 {
00289 GetActiveIP()->PopAllExtensionPlugins();
00290 }
00291
00292 void wxInterfaceManager::CaptureInput(wxIFMComponent *component)
00293 {
00294 wxASSERT_MSG(component, wxT("Invalid component attempting to capture input"));
00295 wxASSERT_MSG(!m_capturedComponent, wxT("A component already has captured input!"));
00296
00297 #if IFM_CANFLOAT
00298 wxIFMFloatingData *data = IFM_GET_EXTENSION_DATA(component, wxIFMFloatingData);
00299 if( data->m_floating )
00300 {
00301 m_floatingCapture = data->m_window;
00302 m_floatingCapture->GetWindow()->CaptureMouse();
00303 }
00304 else
00305 #endif
00306 m_parent->CaptureMouse();
00307
00308 m_capturedComponent = component;
00309 m_capturedType = component->GetType();
00310 }
00311
00312 void wxInterfaceManager::ReleaseInput()
00313 {
00314 wxASSERT_MSG(m_capturedComponent, wxT("Releasing input capture but nothing has captured it!"));
00315 if( !m_capturedComponent )
00316 return;
00317
00318 #if IFM_CANFLOAT
00319 if( m_floatingCapture )
00320 {
00321 m_floatingCapture->GetWindow()->ReleaseMouse();
00322 m_floatingCapture = NULL;
00323 }
00324 else
00325 #endif
00326 m_parent->ReleaseMouse();
00327
00328 m_capturedComponent = NULL;
00329 m_capturedType = IFM_COMPONENT_UNDEFINED;
00330 }
00331
00332 wxWindow *wxInterfaceManager::GetCapturedWindow() const
00333 {
00334 if( !m_capturedComponent )
00335 return NULL;
00336
00337 #if IFM_CANFLOAT
00338 if( m_floatingCapture )
00339 return m_floatingCapture->GetWindow();
00340 else
00341 #endif
00342 return m_parent;
00343 }
00344
00345 void wxInterfaceManager::Update(wxRect rect, bool floating)
00346 {
00347 wxRect *_rect;
00348
00349
00350 if( m_useUpdateRect )
00351 _rect = &m_updateRect;
00352 else
00353 {
00354 if( rect == IFM_DEFAULT_RECT )
00355 m_updateRect = m_parent->GetClientRect();
00356 else
00357 {
00358 m_updateRect = rect;
00359 m_useUpdateRect = true;
00360 }
00361 _rect = &m_updateRect;
00362 }
00363
00364
00365 wxIFMUpdateEvent updevt(m_content, *_rect, floating);
00366 GetActiveIP()->ProcessPluginEvent(updevt);
00367 }
00368
00369 void wxInterfaceManager::AddPendingUpdate(wxRect rect, bool floating)
00370 {
00371 wxRect *_rect;
00372
00373
00374 if( m_useUpdateRect )
00375 _rect = &m_updateRect;
00376 else
00377 {
00378 if( rect == IFM_DEFAULT_RECT )
00379 m_updateRect = m_parent->GetClientRect();
00380 else
00381 {
00382 m_updateRect = rect;
00383 m_useUpdateRect = true;
00384 }
00385 _rect = &m_updateRect;
00386 }
00387
00388
00389 wxIFMUpdateEvent updevt(m_content, *_rect, floating);
00390 GetActiveIP()->AddPendingEvent(updevt);
00391 }
00392
00393 void wxInterfaceManager::SetStatusMessagePane(int pane)
00394 {
00395 m_statusbarPane = pane;
00396 }
00397
00398 void wxInterfaceManager::DisplayStatusMessage(const wxString &message)
00399 {
00400 if( m_statusbarPane != IFM_DISABLE_STATUS_MESSAGES )
00401 {
00402
00403 #if IFM_USE_WX_RTTI
00404 wxFrame *frame = wxDynamicCast(m_parent, wxFrame);
00405 #else
00406 wxFrame *frame = dynamic_cast<wxFrame*>(m_parent);
00407 #endif
00408 if( !frame )
00409 return;
00410
00411 if( !m_statusMessageDisplayed )
00412 {
00413 m_statusMessageDisplayed = true;
00414 m_oldStatusMessage = frame->GetStatusBar()->GetStatusText(m_statusbarPane);
00415 }
00416
00417 frame->GetStatusBar()->SetStatusText(message, m_statusbarPane);
00418 }
00419 }
00420
00421 void wxInterfaceManager::ResetStatusMessage()
00422 {
00423 if( m_statusbarPane != IFM_DISABLE_STATUS_MESSAGES )
00424 {
00425
00426 #if IFM_USE_WX_RTTI
00427 wxFrame *frame = wxDynamicCast(m_parent, wxFrame);
00428 #else
00429 wxFrame *frame = dynamic_cast<wxFrame*>(m_parent);
00430 #endif
00431 if( !frame )
00432 return;
00433
00434 if( m_statusMessageDisplayed )
00435 {
00436 m_statusMessageDisplayed = false;
00437 frame->GetStatusBar()->SetStatusText(m_oldStatusMessage, m_statusbarPane);
00438 m_oldStatusMessage = wxT("");
00439 }
00440 }
00441 }
00442
00443 #if IFM_CANFLOAT
00444
00445
00446
00447
00448 BEGIN_EVENT_TABLE(wxIFMFloatingWindowBase, wxEvtHandler)
00449 EVT_MOUSE_EVENTS (wxIFMFloatingWindowBase::OnMouseEvent)
00450 EVT_PAINT (wxIFMFloatingWindowBase::OnPaint)
00451 EVT_MOVE (wxIFMFloatingWindowBase::OnMoving)
00452 EVT_MOVING (wxIFMFloatingWindowBase::OnMoving)
00453 EVT_SIZE (wxIFMFloatingWindowBase::OnSize)
00454 EVT_SIZING (wxIFMFloatingWindowBase::OnSize)
00455 EVT_KEY_DOWN (wxIFMFloatingWindowBase::OnKeyDown)
00456 EVT_KEY_UP (wxIFMFloatingWindowBase::OnKeyUp)
00457 EVT_SET_CURSOR (wxIFMFloatingWindowBase::OnSetCursor)
00458 EVT_SHOW (wxIFMFloatingWindowBase::OnShow)
00459 EVT_ERASE_BACKGROUND (wxIFMFloatingWindowBase::OnEraseBg)
00460 END_EVENT_TABLE()
00461
00462 wxIFMFloatingWindowBase::wxIFMFloatingWindowBase(wxIFMInterfacePluginBase *ip, wxWindow *parent,
00463 wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name)
00464 : m_ip(ip),
00465 m_component(NULL),
00466 m_destroyRoot(true)
00467 {
00468 m_window = new wxWindow(parent, id, pos, size, style, name);
00469 ConnectEvents();
00470 }
00471
00472 wxIFMFloatingWindowBase::wxIFMFloatingWindowBase(wxIFMInterfacePluginBase *ip)
00473 : m_ip(ip)
00474 { }
00475
00476 wxIFMFloatingWindowBase::~wxIFMFloatingWindowBase()
00477 {
00478 DisconnectEvents();
00479 m_window->Destroy();
00480
00481
00482 if( m_destroyRoot )
00483 {
00484 wxIFMDeleteComponentEvent evt(m_component);
00485 GetIP()->ProcessPluginEvent(evt);
00486 }
00487 }
00488
00489 wxIFMInterfacePluginBase *wxIFMFloatingWindowBase::GetIP()
00490 {
00491 return m_ip;
00492 }
00493
00494 wxInterfaceManager *wxIFMFloatingWindowBase::GetManager()
00495 {
00496 return m_ip->GetManager();
00497 }
00498
00499 wxWindow *wxIFMFloatingWindowBase::GetWindow() const
00500 {
00501 return m_window;
00502 }
00503
00504 wxIFMComponent *wxIFMFloatingWindowBase::GetComponent() const
00505 {
00506 return m_component;
00507 }
00508
00509 void wxIFMFloatingWindowBase::ConnectEvents()
00510 {
00511 m_window->PushEventHandler(this);
00512 }
00513
00514 void wxIFMFloatingWindowBase::DisconnectEvents()
00515 {
00516 m_window->RemoveEventHandler(this);
00517 }
00518
00519 void wxIFMFloatingWindowBase::OnSize(wxSizeEvent &event)
00520 {
00521 wxIFMFloatingSizeEvent sizeevt(
00522 (event.GetEventType() == wxEVT_SIZE ? wxEVT_IFM_FLOATING_SIZE : wxEVT_IFM_FLOATING_SIZING),
00523 this, event);
00524 if( !GetIP()->ProcessPluginEvent(sizeevt) )
00525 event.Skip();
00526 }
00527
00528 void wxIFMFloatingWindowBase::OnMoving(wxMoveEvent &event)
00529 {
00530 wxIFMFloatingMoveEvent moveevt(
00531 (event.GetEventType() == wxEVT_MOVE ? wxEVT_IFM_FLOATING_MOVE : wxEVT_IFM_FLOATING_MOVING),
00532 this, event);
00533 if( !GetIP()->ProcessPluginEvent(moveevt) )
00534 event.Skip();
00535 }
00536
00537 void wxIFMFloatingWindowBase::OnPaint(wxPaintEvent &WXUNUSED(event))
00538 {
00539
00540 wxIFMBeginPaintEvent beginpaint(m_window);
00541 GetIP()->ProcessPluginEvent(beginpaint);
00542
00543 wxDC *dc = beginpaint.GetDC();
00544 wxASSERT_MSG(dc, wxT("Invalid DC returned by EVT_IFM_BEGINPAINT"));
00545
00546 m_component->Paint(*dc, m_window->GetUpdateRegion());
00547
00548
00549 wxIFMEndPaintEvent endpaint(dc);
00550 GetIP()->ProcessPluginEvent(endpaint);
00551 }
00552
00553 void wxIFMFloatingWindowBase::OnKeyDown(wxKeyEvent &event)
00554 {
00555 wxIFMKeyEvent evt(wxEVT_IFM_KEYDOWN, GetManager()->GetCapturedComponent(), event);
00556 if( !GetIP()->ProcessPluginEvent(evt) )
00557 event.Skip();
00558 }
00559
00560 void wxIFMFloatingWindowBase::OnKeyUp(wxKeyEvent &event)
00561 {
00562 wxIFMKeyEvent evt(wxEVT_IFM_KEYUP, GetManager()->GetCapturedComponent(), event);
00563 if( !GetIP()->ProcessPluginEvent(evt) )
00564 event.Skip();
00565 }
00566
00567 void wxIFMFloatingWindowBase::OnSetCursor(wxSetCursorEvent &event)
00568 {
00569 wxIFMSetCursorEvent evt(event, GetComponentByPos(wxPoint(event.GetX(), event.GetY())));
00570 if( !GetIP()->ProcessPluginEvent(evt) )
00571 event.Skip();
00572 }
00573
00574 void wxIFMFloatingWindowBase::OnMouseEvent(wxMouseEvent &event)
00575 {
00576 wxEventType type = 0, _type = event.GetEventType();
00577
00578 if( _type == wxEVT_LEFT_DOWN )
00579 type = wxEVT_IFM_LEFTDOWN;
00580 else if( _type == wxEVT_LEFT_UP )
00581 type = wxEVT_IFM_LEFTUP;
00582 else if( _type == wxEVT_LEFT_DCLICK )
00583 type = wxEVT_IFM_LEFTDCLICK;
00584 else if( _type == wxEVT_RIGHT_DOWN )
00585 type = wxEVT_IFM_RIGHTDOWN;
00586 else if( _type == wxEVT_RIGHT_UP )
00587 type = wxEVT_IFM_RIGHTUP;
00588 else if( _type == wxEVT_RIGHT_DCLICK )
00589 type = wxEVT_IFM_RIGHTDCLICK;
00590 else if( _type == wxEVT_MIDDLE_DOWN )
00591 type = wxEVT_IFM_MIDDLEDOWN;
00592 else if( _type == wxEVT_MIDDLE_UP )
00593 type = wxEVT_IFM_MIDDLEUP;
00594 else if( _type == wxEVT_MIDDLE_DCLICK )
00595 type = wxEVT_IFM_MIDDLEDCLICK;
00596 else if( _type == wxEVT_MOTION )
00597 type = wxEVT_IFM_MOTION;
00598 else if( _type == wxEVT_MOUSEWHEEL )
00599 type = wxEVT_IFM_MOUSEWHEEL;
00600
00601
00602 wxIFMComponent *component = NULL;
00603
00604 if( GetManager()->IsInputCaptured() )
00605 component = GetManager()->GetCapturedComponent();
00606 else
00607 component = GetComponentByPos(event.GetPosition());
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617 wxIFMMouseEvent evt(type, component, event);
00618 if( !GetIP()->ProcessPluginEvent(evt) )
00619 event.Skip();
00620 }
00621
00622 void wxIFMFloatingWindowBase::OnShow(wxShowEvent &event)
00623 {
00624 m_component->Show(event.GetShow(), true);
00625 }
00626
00627 void wxIFMFloatingWindowBase::OnEraseBg(wxEraseEvent &event)
00628 {
00629
00630 }
00631
00632 wxIFMComponent *wxIFMFloatingWindowBase::GetComponentByPos(const wxPoint &pos, wxIFMComponent *component)
00633 {
00634 if( !m_window->IsShown() )
00635 return NULL;
00636 else
00637 return GetIP()->GetComponentByPos(pos, (component == NULL) ? m_component : component);
00638 }
00639
00640 void wxIFMFloatingWindowBase::Update(bool force)
00641 {
00642 if( m_window->IsShown() || force )
00643 {
00644 wxIFMUpdateComponentEvent updevt(m_component, m_component->m_rect);
00645 GetIP()->ProcessPluginEvent(updevt);
00646 }
00647 }
00648
00649 void wxIFMFloatingWindowBase::AddPendingUpdate()
00650 {
00651 if( m_window->IsShown() )
00652 {
00653 wxIFMUpdateComponentEvent updevt(m_component, m_component->m_rect);
00654 GetIP()->AddPendingPluginEvent(updevt);
00655 }
00656 }
00657
00658 #endif
00659
00660
00661
00662
00663 wxIFMComponent::wxIFMComponent(wxIFMInterfacePluginBase *ip, int type)
00664 : m_type(type),
00665 m_ip(ip),
00666 m_minSize(IFM_NO_MINIMUM_SIZE),
00667 m_maxSize(IFM_NO_MAXIMUM_SIZE),
00668 m_fixed(false),
00669 m_hidden(false),
00670 m_visible(true),
00671 m_canHide(true),
00672 m_docked(false),
00673 m_alignment(IFM_ALIGN_NONE),
00674 m_parent(NULL),
00675 m_childType(IFM_CHILDTYPE_UNDEFINED),
00676 m_child(NULL)
00677 {
00678 #if IFM_CANFLOAT
00679
00680 wxIFMExtensionDataBase *data = new wxIFMFloatingData;
00681 m_data[data->GetDataKey()] = data;
00682 #endif
00683 }
00684
00685 wxIFMComponent::wxIFMComponent(const wxIFMComponent &)
00686 { }
00687
00688 wxIFMComponent::~wxIFMComponent()
00689 {
00690
00691 for( wxIFMComponentDataMap::iterator i = m_data.begin(), end = m_data.end(); i != end; ++i )
00692 delete i->second;
00693 }
00694
00695 wxInterfaceManager *wxIFMComponent::GetManager()
00696 {
00697 return m_ip->GetManager();
00698 }
00699
00700 int wxIFMComponent::GetType() const
00701 {
00702 return m_type;
00703 }
00704
00705 void wxIFMComponent::AddExtensionData(wxIFMExtensionDataBase *data)
00706 {
00707 m_data[data->GetDataKey()] = data;
00708 }
00709
00710 wxIFMExtensionDataBase *wxIFMComponent::GetExtensionData(wxIFMComponentDataKeyType key)
00711 {
00712 return m_data[key];
00713 }
00714
00715 wxIFMExtensionDataBase *wxIFMComponent::RemoveExtensionData(wxIFMComponentDataKeyType key)
00716 {
00717 wxIFMExtensionDataBase *ret = m_data[key];
00718 m_data.erase(key);
00719 return ret;
00720 }
00721
00722 int wxIFMComponent::GetNextVisibleComponent(const wxIFMComponentArray &components, int start)
00723 {
00724 for( int i = start, count = components.GetCount(); i < count; ++i )
00725 {
00726 if( !components[i]->m_hidden )
00727 return i;
00728 }
00729
00730
00731 return -1;
00732 }
00733
00734 bool wxIFMComponent::IsChildOf(wxIFMComponent *parent, wxIFMComponent *child)
00735 {
00736 wxIFMComponentArray &children = parent->m_children;
00737 wxIFMComponent *component;
00738 for( int i = 0, size = children.GetCount(); i < size; ++i )
00739
00740 {
00741 component = children[i];
00742
00743
00744 if( component == child )
00745 return true;
00746 else
00747 {
00748
00749 if( wxIFMComponent::IsChildOf(component, child) )
00750 return true;
00751 }
00752 }
00753
00754 return false;
00755 }
00756
00757
00758
00759
00760
00761
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771
00772
00773
00774
00775
00776
00777
00778 void wxIFMComponent::Paint(wxDC &dc, const wxRegion ®ion)
00779 {
00780
00781 wxRect rect = m_rect;
00782
00783
00784 dc.DestroyClippingRegion();
00785 dc.SetClippingRegion(region);
00786
00787
00788 wxIFMPaintEvent bgevt(wxEVT_IFM_PAINTBG, this, region, dc);
00789 m_ip->ProcessPluginEvent(bgevt);
00790
00791
00792 wxIFMPaintEvent bdevt(wxEVT_IFM_PAINTBORDER, this, region, dc);
00793 m_ip->ProcessPluginEvent(bdevt);
00794
00795
00796 wxIFMPaintEvent dcevt(wxEVT_IFM_PAINTDECOR, this, region, dc);
00797 m_ip->ProcessPluginEvent(dcevt);
00798
00799
00800 for( size_t i = 0; i < m_children.GetCount(); i++ )
00801
00802 {
00803
00804 wxIFMComponent *child = m_children[i];
00805
00806
00807 if( child->IsVisible() )
00808 {
00809 wxRegionContain result = region.Contains(child->m_rect);
00810 if( result == wxPartRegion || result == wxInRegion )
00811 {
00812
00813
00814 child->Paint(dc, region);
00815 }
00816 }
00817 }
00818 }
00819
00820 wxWindow *wxIFMComponent::GetParentWindow()
00821 {
00822 #if IFM_CANFLOAT
00823 wxIFMFloatingData *data = IFM_GET_EXTENSION_DATA(this, wxIFMFloatingData);
00824 if( data->m_floating )
00825 return data->m_window->GetWindow();
00826 else
00827 #endif
00828 return GetManager()->GetParent();
00829 }
00830
00831 wxRect wxIFMComponent::GetRect()
00832 {
00833
00834 return m_rect;
00835 }
00836
00837 wxRect wxIFMComponent::GetBackgroundRect()
00838 {
00839 wxIFMRectEvent evt(wxEVT_IFM_GETBACKGROUNDRECT, this);
00840 m_ip->ProcessPluginEvent(evt);
00841 return evt.GetRect();
00842 }
00843
00844 wxRect wxIFMComponent::GetClientRect()
00845 {
00846 wxIFMRectEvent evt(wxEVT_IFM_GETCLIENTRECT, this);
00847 m_ip->ProcessPluginEvent(evt);
00848 return evt.GetRect();
00849 }
00850
00851 wxRect wxIFMComponent::GetConvertedRect(wxRect rect, int coords_from, int coords_to)
00852 {
00853 wxIFMConvertRectEvent evt(this, coords_from, coords_to, rect);
00854 m_ip->ProcessPluginEvent(evt);
00855 return evt.GetRect();
00856 }
00857
00858 wxSize wxIFMComponent::GetDesiredSize()
00859 {
00860 wxIFMRectEvent evt(wxEVT_IFM_GETDESIREDSIZE, this);
00861 m_ip->ProcessPluginEvent(evt);
00862 return evt.GetSize();
00863 }
00864
00865 void wxIFMComponent::SetDesiredSize(const wxSize &size)
00866 {
00867 wxIFMRectEvent evt(wxEVT_IFM_SETDESIREDSIZE, this, wxPoint(), size);
00868 m_ip->ProcessPluginEvent(evt);
00869 }
00870
00871 wxSize wxIFMComponent::GetMinSize()
00872 {
00873 wxIFMRectEvent evt(wxEVT_IFM_GETMINSIZE, this);
00874 m_ip->ProcessPluginEvent(evt);
00875 return evt.GetSize();
00876 }
00877
00878 wxSize wxIFMComponent::GetMaxSize()
00879 {
00880 wxIFMRectEvent evt(wxEVT_IFM_GETMAXSIZE, this);
00881 m_ip->ProcessPluginEvent(evt);
00882 return evt.GetSize();
00883 }
00884
00885 void wxIFMComponent::Show(bool s, bool update)
00886 {
00887 wxIFMShowComponentEvent evt(this, s, update);
00888 m_ip->ProcessPluginEvent(evt);
00889 m_hidden = !s;
00890 }
00891
00892 bool wxIFMComponent::IsShown()
00893 {
00894 return !m_hidden;
00895 }
00896
00897 void wxIFMComponent::VisibilityChanged(bool vis)
00898 {
00899 if( vis == m_visible )
00900 return;
00901
00902 wxIFMComponentVisibilityChangedEvent evt(this, vis);
00903 m_ip->ProcessPluginEvent(evt);
00904 m_visible = vis;
00905 }
00906
00907 bool wxIFMComponent::IsVisible()
00908 {
00909 return (!m_hidden) & m_visible;
00910 }
00911
00912
00913
00914
00915 wxIFMChildDataBase::wxIFMChildDataBase()
00916 : m_type(IFM_CHILDTYPE_UNDEFINED),
00917 m_minSize(IFM_NO_MINIMUM_SIZE),
00918 m_maxSize(IFM_NO_MAXIMUM_SIZE),
00919 m_child(NULL),
00920 m_hidden(false),
00921 m_hideable(true),
00922 m_fixed(false)
00923 { }
00924
00925 wxIFMChildDataBase::wxIFMChildDataBase(wxWindow *child, int type, const wxString &name,
00926 wxSize size, bool hidden, wxSize minSize, wxSize maxSize)
00927 : m_type(type),
00928 m_desiredSize(size),
00929 m_minSize(minSize),
00930 m_maxSize(maxSize),
00931 m_child(child),
00932 m_hidden(hidden),
00933 m_hideable(true),
00934 m_fixed(false),
00935 m_name(name)
00936 { }
00937
00938 wxIFMChildDataBase::wxIFMChildDataBase(const wxIFMChildDataBase &data)
00939 : m_type(data.m_type),
00940 m_desiredSize(data.m_desiredSize),
00941 m_minSize(data.m_minSize),
00942 m_maxSize(data.m_maxSize),
00943 m_child(data.m_child),
00944 m_hidden(data.m_hidden),
00945 m_hideable(data.m_hideable),
00946 m_fixed(data.m_fixed),
00947 m_name(data.m_name)
00948 { }
00949
00950 wxIFMChildDataBase::~wxIFMChildDataBase()
00951 { }
00952
00953
00954
00955
00956 wxIFMExtensionDataBase::~wxIFMExtensionDataBase()
00957 { }
00958
00959 wxIFMComponentDataKeyType wxIFMExtensionDataBase::DataKey()
00960 {
00961 return IFM_COMPONENT_UNDEFINED;
00962 }
00963
00964
00965
00966
00967 #if IFM_CANFLOAT
00968 wxIFMFloatingData::wxIFMFloatingData()
00969 : wxIFMExtensionDataBase(),
00970 m_floating(false),
00971 m_window(NULL),
00972 m_rect(IFM_DEFAULT_RECT)
00973 { }
00974
00975 wxIFMComponentDataKeyType wxIFMFloatingData::GetDataKey() const
00976 {
00977 return IFM_FLOATING_DATA_KEY;
00978 }
00979
00980 wxIFMComponentDataKeyType wxIFMFloatingData::DataKey()
00981 {
00982 return IFM_FLOATING_DATA_KEY;
00983 }
00984
00985 #endif