Beispiel #1
0
 def __init__(self, **kwds):
     style = kwds.get("style", "standard")
     flags = win_calculate_flags(style, kwds)
     # if style == 'fullscreen':
     # 	rect = WinUtils.win_screen_rect
     # else:
     rect = (0, 0, self._default_width, self._default_height)
     frame = ui.CreateFrame()
     frame.CreateWindow(None, "New Window", 0, rect)
     hwnd = frame.GetSafeHwnd()
     # api.SetClassLong(hwnd, wc.GCL_HBRBACKGROUND, win_bg_hbrush)
     api.SetClassLong(hwnd, wc.GCL_HBRBACKGROUND, 0)
     # 		print "Window: Setting style:" ###
     # 		win_deconstruct_style(flags) ###
     frame.ModifyStyle(-1, flags)
     # 		print "Window: Style is now:" ###
     # 		win_deconstruct_style(frame.GetStyle()) ###
     frame.ModifyStyleEx(win_no_ex_flags, win_ex_flags)
     if style == "fullscreen":
         self._win_fullscreen = True
     frame.HookMessage(self._win_wm_initmenu, wc.WM_INITMENU)
     self._win = frame
     if style in win_no_menu_styles:
         self._win_has_menubar = False
     else:
         self._win_set_empty_menubar()
     kwds["closable"] = flags & wc.WS_CAPTION <> 0
     GWindow.__init__(self, _win=frame, **kwds)
Beispiel #2
0
 def __init__(self, style = 'standard', zoomable = None, **kwds):
     # We ignore zoomable, since it's the same as resizable.
     self._style = style
     options = dict(_default_options_for_style[style])
     for option in ['movable', 'closable', 'hidable', 'resizable']:
         if option in kwds:
             options[option] = kwds.pop(option)
     self._ns_style_mask = self._ns_window_style_mask(**options)
     if style == 'fullscreen':
         ns_rect = NSScreen.mainScreen().frame()
     else:
         ns_rect = NSRect(NSPoint(0, 0), NSSize(self._default_width, self._default_height))
     ns_window = PyGUI_NSWindow.alloc()
     ns_window.initWithContentRect_styleMask_backing_defer_(
         ns_rect, self._ns_style_mask, AppKit.NSBackingStoreBuffered, True)
     ns_content = PyGUI_NS_ContentView.alloc()
     ns_content.initWithFrame_(NSRect(NSPoint(0, 0), NSSize(0, 0)))
     ns_content.pygui_component = self
     ns_window.setContentView_(ns_content)
     ns_window.setAcceptsMouseMovedEvents_(True)
     ns_window.setDelegate_(ns_window)
     ns_window.pygui_component = self
     self._ns_window = ns_window
     GWindow.__init__(self, style = style, closable = options['closable'],
         _ns_view = ns_window.contentView(), _ns_responder = ns_window,
         _ns_set_autoresizing_mask = False,
         **kwds)
Beispiel #3
0
 def __init__(self, **kwds):
     style = kwds.get('style', 'standard')
     flags = win_calculate_flags(style, kwds)
     #if style == 'fullscreen':
     #	rect = WinUtils.win_screen_rect
     #else:
     rect = (0, 0, self._default_width, self._default_height)
     frame = ui.CreateFrame()
     frame.CreateWindow(None, "New Window", 0, rect)
     hwnd = frame.GetSafeHwnd()
     #api.SetClassLong(hwnd, wc.GCL_HBRBACKGROUND, win_bg_hbrush)
     api.SetClassLong(hwnd, wc.GCL_HBRBACKGROUND, 0)
     #		print "Window: Setting style:" ###
     #		win_deconstruct_style(flags) ###
     frame.ModifyStyle(-1, flags)
     #		print "Window: Style is now:" ###
     #		win_deconstruct_style(frame.GetStyle()) ###
     frame.ModifyStyleEx(win_no_ex_flags, win_ex_flags)
     if style == 'fullscreen':
         self._win_fullscreen = True
     frame.HookMessage(self._win_wm_initmenu, wc.WM_INITMENU)
     self._win = frame
     if style in win_no_menu_styles:
         self._win_has_menubar = False
     else:
         self._win_set_empty_menubar()
     kwds['closable'] = flags & wc.WS_CAPTION <> 0
     GWindow.__init__(self, _win=frame, **kwds)
Beispiel #4
0
 def __init__(self, style='standard', zoomable=None, **kwds):
     # We ignore zoomable, since it's the same as resizable.
     self._style = style
     options = dict(_default_options_for_style[style])
     for option in ['movable', 'closable', 'hidable', 'resizable']:
         if option in kwds:
             options[option] = kwds.pop(option)
     self._ns_style_mask = self._ns_window_style_mask(**options)
     if style == 'fullscreen':
         ns_rect = NSScreen.mainScreen().frame()
     else:
         ns_rect = NSRect(NSPoint(0, 0),
                          NSSize(self._default_width, self._default_height))
     ns_window = PyGUI_NSWindow.alloc()
     ns_window.initWithContentRect_styleMask_backing_defer_(
         ns_rect, self._ns_style_mask, AppKit.NSBackingStoreBuffered, True)
     ns_content = PyGUI_NS_ContentView.alloc()
     ns_content.initWithFrame_(NSRect(NSPoint(0, 0), NSSize(0, 0)))
     ns_content.pygui_component = self
     ns_window.setContentView_(ns_content)
     ns_window.setAcceptsMouseMovedEvents_(True)
     ns_window.setDelegate_(ns_window)
     ns_window.pygui_component = self
     self._ns_window = ns_window
     GWindow.__init__(self,
                      style=style,
                      closable=options['closable'],
                      _ns_view=ns_window.contentView(),
                      _ns_responder=ns_window,
                      _ns_set_autoresizing_mask=False,
                      **kwds)
Beispiel #5
0
 def _win_install_event_hooks(self):
     self._win.HookMessage(self._wm_activate, wc.WM_ACTIVATE)
     #self._win.HookMessage(self._wm_setfocus, wc.WM_SETFOCUS)
     self._win.HookMessage(self._wm_windowposchanging,
                           wc.WM_WINDOWPOSCHANGING)
     self._win.HookMessage(self._wm_windowposchanged,
                           wc.WM_WINDOWPOSCHANGED)
     GWindow._win_install_event_hooks(self)
Beispiel #6
0
 def _win_wm_setfocus(self, msg):
     # print "Window._win_wm_setfocus:", self ###
     target = self._win_saved_target
     if target and target.window == self:
         # print "...restoring target", target ###
         target._win.SetFocus()
         self._win_saved_target = None
     else:
         GWindow._win_wm_setfocus(self, msg)
Beispiel #7
0
 def _win_wm_setfocus(self, msg):
     #print "Window._win_wm_setfocus:", self ###
     target = self._win_saved_target
     if target and target.window == self:
         #print "...restoring target", target ###
         target._win.SetFocus()
         self._win_saved_target = None
     else:
         GWindow._win_wm_setfocus(self, msg)
Beispiel #8
0
 def __init__(self,
              style='standard',
              title="New Window",
              movable=1,
              closable=1,
              hidable=None,
              resizable=1,
              zoomable=1,
              **kwds):
     self._all_menus = []
     modal = style in _modal_styles
     if hidable is None:
         hidable = not modal
     self._resizable = resizable
     gtk_win = gtk.Window(gtk.WINDOW_TOPLEVEL)
     gtk_win.set_gravity(gdk.GRAVITY_STATIC)
     gtk_win.set_decorated(style <> 'fullscreen'
                           and (movable or closable or hidable or zoomable))
     gtk_win.set_resizable(resizable)
     gtk_win.set_modal(style in _modal_styles)
     gtk_content = gtk.Layout()
     gtk_content.show()
     if style in _dialog_styles:
         gtk_win.set_type_hint(gdk.WINDOW_TYPE_HINT_DIALOG)
         gtk_win.add(gtk_content)
     else:
         self._gtk_create_menubar()
         gtk_box = gtk.VBox()
         gtk_box.show()
         gtk_box.pack_start(self._gtk_menubar, expand=0, fill=0)
         gtk_box.pack_end(gtk_content, expand=1, fill=1)
         gtk_win.add(gtk_box)
     self._need_menubar_update = 1
     self._gtk_connect(gtk_win, 'configure-event',
                       self._gtk_configure_event)
     self._gtk_connect(gtk_win, 'key-press-event',
                       self._gtk_key_press_event)
     self._gtk_connect(gtk_win, 'delete-event', self._gtk_delete_event)
     GWindow.__init__(self,
                      _gtk_outer=gtk_win,
                      _gtk_inner=gtk_content,
                      _gtk_focus=gtk_content,
                      _gtk_input=gtk_content,
                      style=style,
                      title=title,
                      closable=closable)
     if style == 'fullscreen':
         size = (gdk.screen_width(), gdk.screen_height())
     else:
         size = (_default_width, _default_height)
     self.set_size(size)
     self.set(**kwds)
     self.become_target()
Beispiel #9
0
 def __init__(self,
              style='standard',
              title="New Window",
              movable=1,
              closable=1,
              hidable=None,
              resizable=1,
              zoomable=1,
              **kwds):
     self._all_menus = []
     modal = style in _modal_styles
     if hidable is None:
         hidable = not modal
     self._resizable = resizable
     gtk_win = Gtk.Window.new(Gtk.WindowType.TOPLEVEL)
     gtk_win.set_gravity(Gdk.Gravity.STATIC)
     gtk_win.set_decorated(movable or closable or hidable or zoomable)
     gtk_win.set_resizable(resizable)
     gtk_win.set_modal(style in _modal_styles)
     gtk_content = Gtk.Layout()
     gtk_content.show()
     if style in _dialog_styles:
         gtk_win.set_type_hint(Gdk.WindowTypeHint.DIALOG)
         gtk_win.add(gtk_content)
     else:
         self._gtk_create_menubar()
         gtk_box = Gtk.VBox()
         gtk_box.show()
         gtk_box.pack_start(self._gtk_menubar, 0, 0, 0)
         gtk_box.pack_end(gtk_content, 1, 1, 0)
         gtk_win.add(gtk_box)
     self._need_menubar_update = 1
     self._gtk_connect(gtk_win, 'configure-event',
                       self._gtk_configure_event)
     self._gtk_connect(gtk_win, 'key-press-event',
                       self._gtk_key_press_event)
     self._gtk_connect(gtk_win, 'delete-event', self._gtk_delete_event)
     #GtkInput.__init__(self, gtk_content)
     GWindow.__init__(self,
                      _gtk_outer=gtk_win,
                      _gtk_inner=gtk_content,
                      _gtk_focus=gtk_content,
                      _gtk_input=gtk_content,
                      title=title,
                      closable=closable)
     self.set_size((_default_width, _default_height))
     self.set(**kwds)
     self.become_target()
Beispiel #10
0
 def destroy(self):
     #print "Window.destroy:", self ###
     self.hide()
     app = application()
     if app._ns_key_window is self:
         app._ns_key_window = None
     GWindow.destroy(self)
     #  We can't drop all references to the NSWindow yet, because this method
     #  can be called from its windowShouldClose: method, and allowing an
     #  NSWindow to be released while executing one of its own methods seems
     #  to be a very bad idea (Cocoa hangs). So we hide the NSWindow and store
     #  a reference to it in a global. It will be released the next time a
     #  window is closed and the global is re-used.
     global _ns_zombie_window
     _ns_zombie_window = self._ns_window
     self._ns_window.pygui_component = None
Beispiel #11
0
 def destroy(self):
     #print "Window.destroy:", self ###
     self.hide()
     app = application()
     if app._ns_key_window is self:
         app._ns_key_window = None
     GWindow.destroy(self)
     #  We can't drop all references to the NSWindow yet, because this method
     #  can be called from its windowShouldClose: method, and allowing an
     #  NSWindow to be released while executing one of its own methods seems
     #  to be a very bad idea (Cocoa hangs). So we hide the NSWindow and store
     #  a reference to it in a global. It will be released the next time a
     #  window is closed and the global is re-used.
     global _ns_zombie_window
     _ns_zombie_window = self._ns_window
     self._ns_window.pygui_component = None
Beispiel #12
0
 def __init__(self, style = 'standard', title = "New Window",
         movable = 1, closable = 1, hidable = None, resizable = 1,
         zoomable = 1, **kwds):
     self._all_menus = []
     modal = style in _modal_styles
     if hidable is None:
         hidable = not modal
     self._resizable = resizable
     gtk_win = gtk.Window(gtk.WINDOW_TOPLEVEL)
     gtk_win.set_gravity(gdk.GRAVITY_STATIC)
     gtk_win.set_decorated(style <> 'fullscreen'
         and (movable or closable or hidable or zoomable))
     gtk_win.set_resizable(resizable)
     gtk_win.set_modal(style in _modal_styles)
     gtk_content = gtk.Layout()
     gtk_content.show()
     if style in _dialog_styles:
         gtk_win.set_type_hint(gdk.WINDOW_TYPE_HINT_DIALOG)
         gtk_win.add(gtk_content)
     else:
         self._gtk_create_menubar()
         gtk_box = gtk.VBox()
         gtk_box.show()
         gtk_box.pack_start(self._gtk_menubar, expand = 0, fill = 0)
         gtk_box.pack_end(gtk_content, expand = 1, fill = 1)
         gtk_win.add(gtk_box)
     self._need_menubar_update = 1
     self._gtk_connect(gtk_win, 'configure-event', self._gtk_configure_event)
     self._gtk_connect(gtk_win, 'key-press-event', self._gtk_key_press_event)
     self._gtk_connect(gtk_win, 'delete-event', self._gtk_delete_event)
     GWindow.__init__(self, _gtk_outer = gtk_win, _gtk_inner = gtk_content, 
         _gtk_focus = gtk_content, _gtk_input = gtk_content,
         style = style, title = title, closable = closable)
     if style == 'fullscreen':
         size = (gdk.screen_width(), gdk.screen_height())
     else:
         size = (_default_width, _default_height)
     self.set_size(size)
     self.set(**kwds)
     self.become_target()
Beispiel #13
0
 def destroy(self):
     self.hide()
     GWindow.destroy(self)
Beispiel #14
0
 def set_menus(self, x):
     GWindow.set_menus(self, x)
     self._win_menus_changed()
Beispiel #15
0
 def set_menus(self, x):
     GWindow.set_menus(self, x)
     self._win_menus_changed()
Beispiel #16
0
 def _win_install_event_hooks(self):
     self._win.HookMessage(self._wm_activate, wc.WM_ACTIVATE)
     # self._win.HookMessage(self._wm_setfocus, wc.WM_SETFOCUS)
     self._win.HookMessage(self._wm_windowposchanging, wc.WM_WINDOWPOSCHANGING)
     self._win.HookMessage(self._wm_windowposchanged, wc.WM_WINDOWPOSCHANGED)
     GWindow._win_install_event_hooks(self)
Beispiel #17
0
 def set_menus(self, x):
     GWindow.set_menus(self, x)
     self._need_menubar_update = 1
     if self.visible:
         self._gtk_update_menubar()
Beispiel #18
0
 def destroy(self):
     self.hide()
     GWindow.destroy(self)
Beispiel #19
0
 def set_menus(self, x):
     GWindow.set_menus(self, x)
     self._need_menubar_update = 1
     if self.visible:
         self._gtk_update_menubar()