]> git.saurik.com Git - wxWidgets.git/blobdiff - interface/wx/window.h
a few typo-fix and cosmetic changes to wxFlexGridSizer docs
[wxWidgets.git] / interface / wx / window.h
index 3bfeaf9b37a73419deea360fff0968ccd9abc44e..f54958c3120d0b2c51664ee94f1a8f881bfe0463 100644 (file)
@@ -7,32 +7,6 @@
 /////////////////////////////////////////////////////////////////////////////
 
 
-/**
-    Background styles. See wxWindow::SetBackgroundStyle().
-*/
-enum wxBackgroundStyle
-{
-    /// Use the default background, as determined by
-    /// the system or the current theme.
-    wxBG_STYLE_SYSTEM,
-
-    /// Use a solid colour for the background, this style is set automatically if you call
-    /// SetBackgroundColour() so you only need to set it explicitly if you had
-    /// changed the background style to something else before.
-    wxBG_STYLE_COLOUR,
-
-    /// Don't draw the background at all, it's supposed that it is drawn by
-    /// the user-defined erase background event handler.
-    /// This style should be used to avoid flicker when the background is entirely
-    /// custom-drawn.
-    wxBG_STYLE_CUSTOM,
-
-    /// The background is (partially) transparent,this style is automatically set if you call
-    /// SetTransparent() which is used to set the transparency level.
-    wxBG_STYLE_TRANSPARENT
-};
-
-
 /**
     Valid values for wxWindow::ShowWithEffect() and wxWindow::HideWithEffect().
 */
@@ -83,17 +57,6 @@ enum wxWindowVariant
 };
 
 
-/**
-    Flags which can be used in wxWindow::UpdateWindowUI().
-*/
-enum wxUpdateUI
-{
-    wxUPDATE_UI_NONE,
-    wxUPDATE_UI_RECURSE,
-    wxUPDATE_UI_FROMIDLE  /**<  Invoked from On(Internal)Idle */
-};
-
-
 /**
     @class wxWindow
 
@@ -745,10 +708,13 @@ public:
         Merges the window's best size into the min size and returns the result.
         This is the value used by sizers to determine the appropriate
         ammount of space to allocate for the widget.
+        
+        This is the method called by any wxSizer when they query the size
+        of a certain window or control.
 
         @see GetBestSize(), SetInitialSize(), @ref overview_windowsizing
     */
-    wxSize GetEffectiveMinSize() const;
+    virtual wxSize GetEffectiveMinSize() const;
 
     /**
         Returns the maximum size of window's client area.
@@ -1656,6 +1622,9 @@ public:
 
     /**
         @name Event-handling functions
+
+        wxWindow allows you to build a (sort of) stack of event handlers which
+        can be used to override the window's own event handling.
     */
     //@{
 
@@ -1669,9 +1638,8 @@ public:
     wxEvtHandler* GetEventHandler() const;
 
     /**
-        This function will generate the appropriate call to
-        Navigate() if the key event is one normally used for
-        keyboard navigation and return @true in this case.
+        This function will generate the appropriate call to Navigate() if the key
+        event is one normally used for keyboard navigation and return @true in this case.
 
         @return Returns @true if the key pressed was for navigation and was
                 handled, @false otherwise.
@@ -1685,50 +1653,80 @@ public:
         @code
         GetEventHandler()->SafelyProcessEvent(event);
         @endcode
+
+        @see ProcessWindowEvent()
     */
     bool HandleWindowEvent(wxEvent& event) const;
 
+    /**
+        Convenient wrapper for ProcessEvent().
+
+        This is the same as writing @code GetEventHandler()->ProcessEvent(event);
+        @endcode but more convenient. Notice that ProcessEvent() itself can't
+        be called for wxWindow objects as it ignores the event handlers
+        associated with the window, use this function instead.
+    */
+    bool ProcessWindowEvent(wxEvent& event);
+
     /**
         Removes and returns the top-most event handler on the event handler stack.
 
+        E.g. in the case of:
+            @image html overview_eventhandling_winstack.png
+        when calling @c W->PopEventHandler(), the event handler @c A will be
+        removed and @c B will be the first handler of the stack.
+
+        Note that it's an error to call this function when no event handlers
+        were pushed on this window (i.e. when the window itself is its only
+        event handler).
+
         @param deleteHandler
-            If this is @true, the handler will be deleted after it is removed.
-            The default value is @false.
+            If this is @true, the handler will be deleted after it is removed
+            (and the returned value will be @NULL).
 
-        @see SetEventHandler(), GetEventHandler(),
-             PushEventHandler(), wxEvtHandler::ProcessEvent, wxEvtHandler
+        @see @ref overview_eventhandling_processing
     */
     wxEvtHandler* PopEventHandler(bool deleteHandler = false);
 
     /**
         Pushes this event handler onto the event stack for the window.
 
+        An event handler is an object that is capable of processing the events sent
+        to a window. By default, the window is its own event handler, but an application
+        may wish to substitute another, for example to allow central implementation
+        of event-handling for a variety of different window classes.
+
+        wxWindow::PushEventHandler allows an application to set up a @e stack
+        of event handlers, where an event not handled by one event handler is
+        handed to the next one in the chain.
+
+        E.g. if you have two event handlers @c A and @c B and a wxWindow instance
+        @c W and you call:
+        @code
+            W->PushEventHandler(A);
+            W->PushEventHandler(B);
+        @endcode
+        you will end up with the following situation:
+            @image html overview_eventhandling_winstack.png
+
+        Note that you can use wxWindow::PopEventHandler to remove the event handler.
+
         @param handler
             Specifies the handler to be pushed.
+            It must not be part of a wxEvtHandler chain; an assert will fail
+            if it's not unlinked (see wxEvtHandler::IsUnlinked).
 
-        @remarks An event handler is an object that is capable of processing the
-                 events sent to a window. By default, the window is its
-                 own event handler, but an application may wish to
-                 substitute another, for example to allow central
-                 implementation of event-handling for a variety of
-                 different window classes.
-                 wxWindow::PushEventHandler allows an application to set up a
-                 chain of event handlers, where an event not handled by one event
-                 handler is handed to the next one in the chain.
-                 Use wxWindow::PopEventHandler to remove the event handler.
-
-        @see SetEventHandler(), GetEventHandler(),
-             PopEventHandler(), wxEvtHandler::ProcessEvent, wxEvtHandler
+        @see @ref overview_eventhandling_processing
     */
     void PushEventHandler(wxEvtHandler* handler);
 
     /**
-        Find the given @a handler in the windows event handler chain and remove
-        (but not delete) it from it.
+        Find the given @a handler in the windows event handler stack and unlinks
+        (but not delete) it. See wxEvtHandler::Unlink() for more info.
 
         @param handler
             The event handler to remove, must be non-@NULL and
-            must be present in this windows event handlers chain
+            must be present in this windows event handlers stack.
 
         @return Returns @true if it was found and @false otherwise (this also
                 results in an assert failure so this function should
@@ -1741,27 +1739,41 @@ public:
     /**
         Sets the event handler for this window.
 
+        Note that if you use this function you may want to use as the "next" handler
+        of @a handler the window itself; in this way when @a handler doesn't process
+        an event, the window itself will have a chance to do it.
+
         @param handler
-            Specifies the handler to be set.
-
-        @remarks An event handler is an object that is capable of processing the
-                 events sent to a window. By default, the window is its
-                 own event handler, but an application may wish to
-                 substitute another, for example to allow central
-                 implementation of event-handling for a variety of
-                 different window classes.
-                 It is usually better to use wxWindow::PushEventHandler since
-                 this sets up a chain of event handlers, where an event not
-                handled by one event handler is handed to the next one in the chain.
-
-        @see GetEventHandler(), PushEventHandler(),
-             PopEventHandler(), wxEvtHandler::ProcessEvent, wxEvtHandler
+            Specifies the handler to be set. Cannot be @NULL.
+
+        @see @ref overview_eventhandling_processing
     */
     void SetEventHandler(wxEvtHandler* handler);
 
+    /**
+        wxWindows cannot be used to form event handler chains; this function
+        thus will assert when called.
+
+        Note that instead you can use PushEventHandler() or SetEventHandler() to
+        implement a stack of event handlers to override wxWindow's own
+        event handling mechanism.
+    */
+    virtual void SetNextHandler(wxEvtHandler* handler);
+
+    /**
+        wxWindows cannot be used to form event handler chains; this function
+        thus will assert when called.
+
+        Note that instead you can use PushEventHandler() or SetEventHandler() to
+        implement a stack of event handlers to override wxWindow's own
+        event handling mechanism.
+    */
+    virtual void SetPreviousHandler(wxEvtHandler* handler);
+
     //@}
 
 
+
     /**
         @name Window styles functions
     */
@@ -2858,7 +2870,7 @@ public:
         are concerned). This may be necessary if you have called
         wxUpdateUIEvent::SetMode() or wxUpdateUIEvent::SetUpdateInterval() to limit
         the overhead that wxWidgets incurs by sending update UI events in idle time.
-        @a flags should be a bitlist of one or more of the wxUpdateUI enumeration.
+        @a flags should be a bitlist of one or more of the ::wxUpdateUI enumeration.
 
         If you are calling this function from an OnInternalIdle or OnIdle
         function, make sure you pass the wxUPDATE_UI_FROMIDLE flag, since
@@ -3052,6 +3064,36 @@ protected:
         explanations of when you might want to do it.
      */
     void SendDestroyEvent();
+
+    /**
+        This function is public in wxEvtHandler but protected in wxWindow
+        because for wxWindows you should always call ProcessEvent() on the
+        pointer returned by GetEventHandler() and not on the wxWindow object
+        itself.
+
+        For convenience, a ProcessWindowEvent() method is provided as a synonym
+        for @code GetEventHandler()->ProcessEvent() @endcode.
+
+        Note that it's still possible to call these functions directly on the
+        wxWindow object (e.g. casting it to wxEvtHandler) but doing that will
+        create subtle bugs when windows with event handlers pushed on them are
+        involved.
+
+        This holds also for all other wxEvtHandler functions.
+    */
+    virtual bool ProcessEvent(wxEvent& event);
+
+    //@{
+    /**
+        See ProcessEvent() for more info about why you shouldn't use this function
+        and the reason for making this function protected in wxWindow.
+    */
+    bool SafelyProcessEvent(wxEvent& event);
+    virtual void QueueEvent(wxEvent *event);
+    virtual void AddPendingEvent(const wxEvent& event);
+    void ProcessPendingEvents();
+    bool ProcessThreadEvent(const wxEvent& event);
+    //@}
 };