def OnDrop(self, x, y): screen_position = ClientGUICommon.ClientToScreen(self._parent, (x, y)) drop_tlp = ClientGUICommon.GetXYTopTLP(screen_position) my_tlp = ClientGUICommon.GetTLP(self._parent) if drop_tlp == my_tlp: return True else: return False
def _GetIdealSizeAndPosition( self ): parent = self.GetParent() ( parent_width, parent_height ) = parent.GetClientSize() ( my_width, my_height ) = self.GetSize() my_ideal_width = int( parent_width * 0.2 ) should_resize = my_ideal_width != my_width ideal_size = ( my_ideal_width, -1 ) ideal_position = ClientGUICommon.ClientToScreen( parent, ( int( parent_width * 0.8 ), 0 ) ) return ( should_resize, ideal_size, ideal_position )
def _SizeAndPositionAndShow( self ): try: parent = self.GetParent() # changing show status while parent iconised in Windows leads to grey window syndrome windows_and_iconised = HC.PLATFORM_WINDOWS and parent.IsIconized() possibly_on_hidden_virtual_desktop = not ClientGUITopLevelWindows.MouseIsOnMyDisplay( parent ) going_to_bug_out_at_hide_or_show = windows_and_iconised or possibly_on_hidden_virtual_desktop current_focus_tlp = wx.GetTopLevelParent( wx.Window.FindFocus() ) main_gui_is_active = current_focus_tlp in ( self, parent ) on_top_frame_is_active = False if not main_gui_is_active: c_f_tlp_is_child_frame_of_main_gui = isinstance( current_focus_tlp, wx.Frame ) and current_focus_tlp.GetParent() == parent if c_f_tlp_is_child_frame_of_main_gui and current_focus_tlp.GetWindowStyle() & wx.FRAME_FLOAT_ON_PARENT == wx.FRAME_FLOAT_ON_PARENT: on_top_frame_is_active = True num_messages_displayed = self._message_vbox.GetItemCount() there_is_stuff_to_display = num_messages_displayed > 0 if there_is_stuff_to_display: # little catch here to try to stop the linux users who got infinitely expanding popups wew popup_message_character_width = HG.client_controller.new_options.GetInteger( 'popup_message_character_width' ) wrap_width = ClientGUICommon.ConvertTextToPixelWidth( self, popup_message_character_width ) max_width = wrap_width * 1.2 ( best_width, best_height ) = self.GetBestSize() best_width = min( best_width, max_width ) best_size = ( best_width, best_height ) if best_size != self._last_best_size_i_fit_on: self._last_best_size_i_fit_on = best_size self.SetClientSize( best_size ) self.Layout() ( parent_width, parent_height ) = parent.GetClientSize() ( my_width, my_height ) = self.GetClientSize() my_x = ( parent_width - my_width ) - 25 my_y = ( parent_height - my_height ) - 5 if parent.IsShown(): my_position = ClientGUICommon.ClientToScreen( parent, ( my_x, my_y ) ) if my_position != self.GetPosition(): self.SetPosition( my_position ) # Unhiding tends to raise the main gui tlp, which is annoying if a media viewer window has focus show_is_not_annoying = main_gui_is_active or on_top_frame_is_active or self._DisplayingError() ok_to_show = show_is_not_annoying and not going_to_bug_out_at_hide_or_show if ok_to_show: was_hidden = not self.IsShown() self.Show() if was_hidden: self.Layout() self.Refresh() else: if not going_to_bug_out_at_hide_or_show: self.Hide() except: text = 'The popup message manager experienced a fatal error and will now stop working! Please restart the client as soon as possible! If this keeps happening, please email the details and your client.log to the hydrus developer.' HydrusData.Print( text ) HydrusData.Print( traceback.format_exc() ) wx.MessageBox( text ) self._update_job.Cancel() self.CleanBeforeDestroy() self.DestroyLater()