Rapicorn - Experimental UI Toolkit - Source Code  13.07.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
window.hh
Go to the documentation of this file.
00001  // Licensed GNU LGPL v3 or later: http://www.gnu.org/licenses/lgpl.html
00002 #ifndef __RAPICORN_WINDOW_HH__
00003 #define __RAPICORN_WINDOW_HH__
00004 
00005 #include <ui/viewport.hh>
00006 #include <ui/screenwindow.hh>
00007 
00008 namespace Rapicorn {
00009 
00010 /* --- Window --- */
00011 class WindowImpl : public virtual ViewportImpl, public virtual WindowIface {
00012   friend class  WidgetImpl;
00013   EventLoop            &loop_;
00014   ScreenWindow*         screen_window_;
00015   EventContext          last_event_context_;
00016   Signal_commands::Emission *commands_emission_;
00017   String                     last_command_;
00018   vector<WidgetImpl*>     last_entered_children_;
00019   ScreenWindow::Config  config_;
00020   uint                  notify_displayed_id_;
00021   uint                  auto_focus_ : 1;
00022   uint                  entered_ : 1;
00023   uint                  pending_win_size_ : 1;
00024   uint                  pending_expose_ : 1;
00025   void          uncross_focus           (WidgetImpl        &fwidget);
00026 protected:
00027   void          set_focus               (WidgetImpl         *widget);
00028   virtual void  set_parent              (ContainerImpl    *parent);
00029   virtual void  dispose                 ();
00030 public:
00031   static const int      PRIORITY_RESIZE         = EventLoop::PRIORITY_UPDATE - 1; 
00032   explicit              WindowImpl              ();
00033   virtual WindowImpl*   as_window_impl          ()              { return this; }
00034   WidgetImpl*             get_focus               () const;
00035   cairo_surface_t*      create_snapshot         (const Rect  &subarea);
00036   static  void          forcefully_close_all    ();
00037   // properties
00038   virtual String        title                   () const;
00039   virtual void          title                   (const String &window_title);
00040   virtual bool          auto_focus              () const;
00041   virtual void          auto_focus              (bool afocus);
00042   // grab handling
00043   virtual void          add_grab                                (WidgetImpl &child, bool unconfined = false);
00044   void                  add_grab                                (WidgetImpl *child, bool unconfined = false);
00045   virtual void          remove_grab                             (WidgetImpl &child);
00046   void                  remove_grab                             (WidgetImpl *child);
00047   virtual WidgetImpl*     get_grab                                (bool                   *unconfined = NULL);
00048   // main loop
00049   virtual EventLoop*    get_loop                                ();
00050   // signals
00051   typedef Aida::Signal<void ()> NotifySignal;
00052   /* WindowIface */
00053   virtual bool          viewable                                ();
00054   virtual void          show                                    ();
00055   virtual bool          closed                                  ();
00056   virtual void          close                                   ();
00057   virtual bool          snapshot                                (const String &pngname);
00058   virtual bool          synthesize_enter                        (double xalign = 0.5,
00059                                                                  double yalign = 0.5);
00060   virtual bool          synthesize_leave                        ();
00061   virtual bool          synthesize_click                        (WidgetIface &widget,
00062                                                                  int        button,
00063                                                                  double     xalign = 0.5,
00064                                                                  double     yalign = 0.5);
00065   virtual bool          synthesize_delete                       ();
00066   void                  draw_child                              (WidgetImpl &child);
00067 private:
00068   void                  notify_displayed                        (void);
00069   virtual void          remove_grab_widget                      (WidgetImpl               &child);
00070   void                  grab_stack_changed                      ();
00071   virtual              ~WindowImpl                              ();
00072   virtual void          dispose_widget                          (WidgetImpl               &widget);
00073   /* misc */
00074   vector<WidgetImpl*>   widget_difference                       (const vector<WidgetImpl*>    &clist, /* preserves order of clist */
00075                                                                  const vector<WidgetImpl*>    &cminus);
00076   /* sizing */
00077   void                  resize_window                           (const Allocation *new_area = NULL);
00078   virtual void          do_invalidate                           ();
00079   virtual void          beep                                    ();
00080   /* rendering */
00081   virtual void          draw_now                                ();
00082   virtual void          render                                  (RenderContext &rcontext, const Rect &rect);
00083   /* screen_window ops */
00084   virtual void          create_screen_window                    ();
00085   virtual bool          has_screen_window                       ();
00086   virtual void          destroy_screen_window                   ();
00087   void                  idle_show                               ();
00088   /* main loop */
00089   virtual bool          event_dispatcher                        (const EventLoop::State &state);
00090   virtual bool          resizing_dispatcher                     (const EventLoop::State &state);
00091   virtual bool          drawing_dispatcher                      (const EventLoop::State &state);
00092   virtual bool          command_dispatcher                      (const EventLoop::State &state);
00093   virtual bool          custom_command                          (const String       &command_name,
00094                                                                  const StringSeq    &command_args);
00095   /* event handling */
00096   virtual void          cancel_widget_events                      (WidgetImpl               *widget);
00097   void                  cancel_widget_events                      (WidgetImpl &widget) { cancel_widget_events (&widget); }
00098   bool                  dispatch_mouse_movement                 (const Event            &event);
00099   bool                  dispatch_event_to_pierced_or_grab       (const Event            &event);
00100   bool                  dispatch_button_press                   (const EventButton      &bevent);
00101   bool                  dispatch_button_release                 (const EventButton      &bevent);
00102   bool                  dispatch_cancel_event                   (const Event            &event);
00103   bool                  dispatch_enter_event                    (const EventMouse       &mevent);
00104   bool                  dispatch_move_event                     (const EventMouse       &mevent);
00105   bool                  dispatch_leave_event                    (const EventMouse       &mevent);
00106   bool                  dispatch_button_event                   (const Event            &event);
00107   bool                  dispatch_focus_event                    (const EventFocus       &fevent);
00108   bool                  move_focus_dir                          (FocusDirType            focus_dir);
00109   bool                  dispatch_key_event                      (const Event            &event);
00110   bool                  dispatch_scroll_event                   (const EventScroll      &sevent);
00111   bool                  dispatch_win_size_event                 (const Event            &event);
00112   bool                  dispatch_win_delete_event               (const Event            &event);
00113   bool                  dispatch_win_destroy                    ();
00114   virtual bool          dispatch_event                          (const Event            &event);
00115   bool                  has_queued_win_size                     ();
00116   /* --- GrabEntry --- */
00117   struct GrabEntry {
00118     WidgetImpl *widget;
00119     bool  unconfined;
00120     explicit            GrabEntry (WidgetImpl *i, bool uc) : widget (i), unconfined (uc) {}
00121   };
00122   vector<GrabEntry>     grab_stack_;
00123   /* --- ButtonState --- */
00124   struct ButtonState {
00125     WidgetImpl           *widget;
00126     uint                button;
00127     explicit            ButtonState     (WidgetImpl *i, uint b) : widget (i), button (b) {}
00128     explicit            ButtonState     () : widget (NULL), button (0) {}
00129     bool                operator< (const ButtonState &bs2) const
00130     {
00131       const ButtonState &bs1 = *this;
00132       return bs1.widget < bs2.widget || (bs1.widget == bs2.widget &&
00133                                      bs1.button < bs2.button);
00134     }
00135   };
00136   map<ButtonState,uint> button_state_map_;
00137 };
00138 
00139 } // Rapicorn
00140 
00141 #endif  /* __RAPICORN_WINDOW_HH__ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines