/////////////////////////////////////////////////////////////////////////////
-// Name: src/common/window.cpp
+// Name: src/common/wincmn.cpp
// Purpose: common (to all ports) wxWindow functions
// Author: Julian Smart, Vadim Zeitlin
// Modified by:
wxMenu *wxCurrentPopupMenu = NULL;
#endif // wxUSE_MENUS
+extern WXDLLEXPORT_DATA(const char) wxPanelNameStr[] = "panel";
+
// ----------------------------------------------------------------------------
// static data
// ----------------------------------------------------------------------------
// implementation of the common functionality of the wxWindow class
// ============================================================================
+// ----------------------------------------------------------------------------
+// XTI
+// ----------------------------------------------------------------------------
+
+#if wxUSE_EXTENDED_RTTI
+
+// windows that are created from a parent window during its Create method,
+// eg. spin controls in a calendar controls must never been streamed out
+// separately otherwise chaos occurs. Right now easiest is to test for negative ids,
+// as windows with negative ids never can be recreated anyway
+
+
+bool wxWindowStreamingCallback( const wxObject *object, wxObjectWriter *,
+ wxObjectWriterCallback *, const wxStringToAnyHashMap & )
+{
+ const wxWindow * win = wx_dynamic_cast(const wxWindow*, object);
+ if ( win && win->GetId() < 0 )
+ return false;
+ return true;
+}
+
+wxIMPLEMENT_DYNAMIC_CLASS_XTI_CALLBACK(wxWindow, wxWindowBase, "wx/window.h", \
+ wxWindowStreamingCallback)
+
+// make wxWindowList known before the property is used
+
+wxCOLLECTION_TYPE_INFO( wxWindow*, wxWindowList );
+
+template<> void wxCollectionToVariantArray( wxWindowList const &theList,
+ wxAnyList &value)
+{
+ wxListCollectionToAnyList<wxWindowList::compatibility_iterator>( theList, value );
+}
+
+wxDEFINE_FLAGS( wxWindowStyle )
+
+wxBEGIN_FLAGS( wxWindowStyle )
+// new style border flags, we put them first to
+// use them for streaming out
+
+wxFLAGS_MEMBER(wxBORDER_SIMPLE)
+wxFLAGS_MEMBER(wxBORDER_SUNKEN)
+wxFLAGS_MEMBER(wxBORDER_DOUBLE)
+wxFLAGS_MEMBER(wxBORDER_RAISED)
+wxFLAGS_MEMBER(wxBORDER_STATIC)
+wxFLAGS_MEMBER(wxBORDER_NONE)
+
+// old style border flags
+wxFLAGS_MEMBER(wxSIMPLE_BORDER)
+wxFLAGS_MEMBER(wxSUNKEN_BORDER)
+wxFLAGS_MEMBER(wxDOUBLE_BORDER)
+wxFLAGS_MEMBER(wxRAISED_BORDER)
+wxFLAGS_MEMBER(wxSTATIC_BORDER)
+wxFLAGS_MEMBER(wxBORDER)
+
+// standard window styles
+wxFLAGS_MEMBER(wxTAB_TRAVERSAL)
+wxFLAGS_MEMBER(wxCLIP_CHILDREN)
+wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW)
+wxFLAGS_MEMBER(wxWANTS_CHARS)
+wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE)
+wxFLAGS_MEMBER(wxALWAYS_SHOW_SB )
+wxFLAGS_MEMBER(wxVSCROLL)
+wxFLAGS_MEMBER(wxHSCROLL)
+
+wxEND_FLAGS( wxWindowStyle )
+
+wxBEGIN_PROPERTIES_TABLE(wxWindow)
+wxEVENT_PROPERTY( Close, wxEVT_CLOSE_WINDOW, wxCloseEvent)
+wxEVENT_PROPERTY( Create, wxEVT_CREATE, wxWindowCreateEvent )
+wxEVENT_PROPERTY( Destroy, wxEVT_DESTROY, wxWindowDestroyEvent )
+// Always constructor Properties first
+
+wxREADONLY_PROPERTY( Parent,wxWindow*, GetParent, wxEMPTY_PARAMETER_VALUE, \
+ 0 /*flags*/, wxT("Helpstring"), wxT("group"))
+wxPROPERTY( Id,wxWindowID, SetId, GetId, -1 /*wxID_ANY*/, 0 /*flags*/, \
+ wxT("Helpstring"), wxT("group") )
+wxPROPERTY( Position,wxPoint, SetPosition, GetPosition, wxDefaultPosition, \
+ 0 /*flags*/, wxT("Helpstring"), wxT("group")) // pos
+wxPROPERTY( Size,wxSize, SetSize, GetSize, wxDefaultSize, 0 /*flags*/, \
+ wxT("Helpstring"), wxT("group")) // size
+wxPROPERTY( WindowStyle, long, SetWindowStyleFlag, GetWindowStyleFlag, \
+ wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, wxT("Helpstring"), wxT("group")) // style
+wxPROPERTY( Name,wxString, SetName, GetName, wxEmptyString, 0 /*flags*/, \
+ wxT("Helpstring"), wxT("group") )
+
+// Then all relations of the object graph
+
+wxREADONLY_PROPERTY_COLLECTION( Children, wxWindowList, wxWindowBase*, \
+ GetWindowChildren, wxPROP_OBJECT_GRAPH /*flags*/, \
+ wxT("Helpstring"), wxT("group"))
+
+// and finally all other properties
+
+wxPROPERTY( ExtraStyle, long, SetExtraStyle, GetExtraStyle, wxEMPTY_PARAMETER_VALUE, \
+ 0 /*flags*/, wxT("Helpstring"), wxT("group")) // extstyle
+wxPROPERTY( BackgroundColour, wxColour, SetBackgroundColour, GetBackgroundColour, \
+ wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, wxT("Helpstring"), wxT("group")) // bg
+wxPROPERTY( ForegroundColour, wxColour, SetForegroundColour, GetForegroundColour, \
+ wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, wxT("Helpstring"), wxT("group")) // fg
+wxPROPERTY( Enabled, bool, Enable, IsEnabled, wxAny((bool)true), 0 /*flags*/, \
+ wxT("Helpstring"), wxT("group"))
+wxPROPERTY( Shown, bool, Show, IsShown, wxAny((bool)true), 0 /*flags*/, \
+ wxT("Helpstring"), wxT("group"))
+
+#if 0
+// possible property candidates (not in xrc) or not valid in all subclasses
+wxPROPERTY( Title,wxString, SetTitle, GetTitle, wxEmptyString )
+wxPROPERTY( Font, wxFont, SetFont, GetWindowFont , )
+wxPROPERTY( Label,wxString, SetLabel, GetLabel, wxEmptyString )
+// MaxHeight, Width, MinHeight, Width
+// TODO switch label to control and title to toplevels
+
+wxPROPERTY( ThemeEnabled, bool, SetThemeEnabled, GetThemeEnabled, )
+//wxPROPERTY( Cursor, wxCursor, SetCursor, GetCursor, )
+// wxPROPERTY( ToolTip, wxString, SetToolTip, GetToolTipText, )
+wxPROPERTY( AutoLayout, bool, SetAutoLayout, GetAutoLayout, )
+#endif
+wxEND_PROPERTIES_TABLE()
+
+wxEMPTY_HANDLERS_TABLE(wxWindow)
+
+wxCONSTRUCTOR_DUMMY(wxWindow)
+
+#else
+
+#ifndef __WXUNIVERSAL__
+IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxWindowBase)
+#endif
+
+#endif
+
// ----------------------------------------------------------------------------
// initialization
// ----------------------------------------------------------------------------
bool wxWindowBase::Destroy()
{
- SendDestroyEvent();
+ // If our handle is invalid, it means that this window has never been
+ // created, either because creating it failed or, more typically, because
+ // this wxWindow object was default-constructed and its Create() method had
+ // never been called. As we didn't send wxWindowCreateEvent in this case
+ // (which is sent after successful creation), don't send the matching
+ // wxWindowDestroyEvent neither.
+ if ( GetHandle() )
+ SendDestroyEvent();
delete this;
return size*2;
}
+bool
+wxWindowBase::InformFirstDirection(int direction,
+ int size,
+ int availableOtherDir)
+{
+ return GetSizer() && GetSizer()->InformFirstDirection(direction,
+ size,
+ availableOtherDir);
+}
+
wxSize wxWindowBase::GetEffectiveMinSize() const
{
// merge the best size with the min size, giving priority to the min size
wxSizeEvent event(GetSize(), GetId());
event.SetEventObject(this);
if ( flags & wxSEND_EVENT_POST )
- wxPostEvent(this, event);
+ wxPostEvent(GetEventHandler(), event);
else
HandleWindowEvent(event);
}
// wxWidgets versions where GetBackgroundColour() always returned
// something -- so give them something even if it doesn't make sense
// for this window (e.g. it has a themed background)
- if ( !colBg.Ok() )
+ if ( !colBg.IsOk() )
colBg = GetClassDefaultAttributes().colBg;
return colBg;
wxColour wxWindowBase::GetForegroundColour() const
{
// logic is the same as above
- if ( !m_hasFgCol && !m_foregroundColour.Ok() )
+ if ( !m_hasFgCol && !m_foregroundColour.IsOk() )
{
wxColour colFg = GetDefaultAttributes().colFg;
m_inheritBgCol = m_hasBgCol;
m_backgroundColour = colour;
- SetThemeEnabled( !m_hasBgCol && !m_foregroundColour.Ok() );
+ SetThemeEnabled( !m_hasBgCol && !m_foregroundColour.IsOk() );
return true;
}
m_hasFgCol = colour.IsOk();
m_inheritFgCol = m_hasFgCol;
m_foregroundColour = colour;
- SetThemeEnabled( !m_hasFgCol && !m_backgroundColour.Ok() );
+ SetThemeEnabled( !m_hasFgCol && !m_backgroundColour.IsOk() );
return true;
}
}
}
+bool wxWindowBase::CopyToolTip(wxToolTip *tip)
+{
+ SetToolTip(tip ? new wxToolTip(tip->GetTip()) : NULL);
+
+ return tip != NULL;
+}
+
#endif // wxUSE_TOOLTIPS
// ----------------------------------------------------------------------------
Show(event.GetShown());
}
+// ----------------------------------------------------------------------------
+// Idle processing
+// ----------------------------------------------------------------------------
+
+// Send idle event to window and all subwindows
+bool wxWindowBase::SendIdleEvents(wxIdleEvent& event)
+{
+ bool needMore = false;
+
+ OnInternalIdle();
+
+ // should we send idle event to this window?
+ if (wxIdleEvent::GetMode() == wxIDLE_PROCESS_ALL ||
+ HasExtraStyle(wxWS_EX_PROCESS_IDLE))
+ {
+ event.SetEventObject(this);
+ HandleWindowEvent(event);
+
+ if (event.MoreRequested())
+ needMore = true;
+ }
+ wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
+ for (; node; node = node->GetNext())
+ {
+ wxWindow* child = node->GetData();
+ if (child->SendIdleEvents(event))
+ needMore = true;
+ }
+
+ return needMore;
+}
+
+void wxWindowBase::OnInternalIdle()
+{
+ if ( wxUpdateUIEvent::CanUpdate(this) )
+ UpdateWindowUI(wxUPDATE_UI_FROMIDLE);
+}
+
// ----------------------------------------------------------------------------
// dialog units translations
// ----------------------------------------------------------------------------
else
#endif // __WXDEBUG__
{
+#if wxUSE_MSGDLG
// just Ctrl-Alt-middle click shows information about wx version
::wxInfoMessageBox((wxWindow*)this);
+#endif // wxUSE_MSGDLG
}
}
else
// list classes implementation
// ----------------------------------------------------------------------------
-#if wxUSE_STL
+#if wxUSE_STD_CONTAINERS
#include "wx/listimpl.cpp"
WX_DEFINE_LIST(wxWindowList)
-#else // !wxUSE_STL
+#else // !wxUSE_STD_CONTAINERS
void wxWindowListNode::DeleteData()
{
delete (wxWindow *)GetData();
}
-#endif // wxUSE_STL/!wxUSE_STL
+#endif // wxUSE_STD_CONTAINERS/!wxUSE_STD_CONTAINERS
// ----------------------------------------------------------------------------
// borders
wxWindowList::compatibility_iterator i = siblings.Find(win);
wxCHECK_RET( i, wxT("MoveBefore/AfterInTabOrder(): win is not a sibling") );
- // unfortunately, when wxUSE_STL == 1 DetachNode() is not implemented so we
- // can't just move the node around
+ // unfortunately, when wxUSE_STD_CONTAINERS == 1 DetachNode() is not
+ // implemented so we can't just move the node around
wxWindow *self = (wxWindow *)this;
siblings.DeleteObject(self);
if ( move == OrderAfter )
bool wxWindowBase::HasFocus() const
{
- wxWindowBase *win = DoFindFocus();
- return win == this ||
- win == wxConstCast(this, wxWindowBase)->GetMainWindowOfCompositeControl();
+ wxWindowBase* const win = DoFindFocus();
+ return win &&
+ (this == win || this == win->GetMainWindowOfCompositeControl());
}
// ----------------------------------------------------------------------------