
    Je'                         d dl Z d dlmZ d dlmZ d dlmZ d dlmZm	Z	 d dl
mZ d dlmZ d dlmZ  G d	 d
e      Z G d de	      Zy)    N)Qt)QColor)QToolBar)QPrinterQPrintPreviewDialog)_)ima)PANES_TOOLBAR_STYLESHEETc                   2    e Zd Zej                  dfdZd Zy)SpyderPrinterNc                     t        j                  | |       | j                  t         j                         | j	                  t         j
                         t        j                         | _        ||| _	        y y N)
r   __init__setColorModeColorsetPageOrderFirstPageFirsttimectimedateheader_font)selfmoder   s      G/usr/lib/python3/dist-packages/spyder/plugins/editor/widgets/printer.pyr   zSpyderPrinter.__init__   sX    $%(..)(112JJL	"*D #    c                 p   | j                         d| j                  d|}|j                          |j                  | j                         |j                  t        t        j                               |rn|j                  |j                         |j                         j                  |      z
  |j                         |j                         j                         z   |       |j                  |j                         |j                         j!                         z   dz          |j#                          y )Nz - z - Page    )docNamer   savesetFontr   setPenr   r   blackdrawTextrightfontMetricswidthtopascentsetTopheightrestore)r   painterdrawingareapagenrheaders         r   
formatPagezSpyderPrinter.formatPage   s    (,		6J(()vbhh'(TZZ\'*=*=*?*E*Ef*MM!XXZ(;(;(=(D(D(FFPDHHJw224;;==a?@r   )__name__
__module____qualname__r   ScreenResolutionr   r1    r   r   r   r      s    $554 +	r   r   c                   :     e Zd ZdZd fd	Zd Zd Z fdZ xZS )SpyderPrintPreviewDialogzc
    Subclass to make the default Qt dialog conform to the style and icons used
    in Spyder.
    c                     t         |   ||       | j                  t              d   | _        | j                          | j                          y )Nr   )superr   findChildrenr   toolbaradjust_toolbar_stylemake_tooltips_translatable)r   printerparent	__class__s      r   r   z!SpyderPrintPreviewDialog.__init__1   sA    &)((215!!#'')r   c                    | j                   j                  t        t                     | j                   j	                  d       | j                   j                         }|d   j                  t        j                  d             |d   j                  t        j                  d             |d   j                  d       |d   j                  t        j                  d             |d	   j                  t        j                  d
             |d   j                  d       |d   j                  t        j                  d             |d   j                  t        j                  d             |d   j                  d       |d   j                  t        j                  d             |d   j                  t        j                  d             |d   j                  t        j                  d             |d   j                  t        j                  d             |d   j                  d       |d   j                  t        j                  d             |d   j                  d       |d   j                  t        j                  d             |d   j                  d       |d    j                  t        j                  d!             |d"   j                  t        j                  d#             y$)%z$Make toolbar to follow Spyder style.Fr   zprint.fit_width   zprint.fit_page      zoom_outr   zoom_in      portrait   	landscape	   
   
first_page   previous_page   	next_page   	last_page      zprint.single_page      zprint.all_pages      zprint.page_setup   printN)
r<   setStyleSheetstrr
   
setMovableactionssetIconr	   icon
setVisible)r   ra   s     r   r=   z-SpyderPrintPreviewDialog.adjust_toolbar_style8   s)   ""3'?#@A&,,&&(
388$567
388$456
e$
388J/0
388I./
e$
388J/0
388K01
e$CHH\23CHH_56CHH[12CHH[12u%CHH%89:u%CHH%678u%CHH%789CHHW-.r   c                    dt        d      fdt        d      fdt        d      fdt        d      fd	t        d
      fdt        d      fdt        d      fdt        d      fdt        d      fdt        d      fdt        d      fdt        d      fdt        d      fdt        d      fg}| j                  j                         }|D ]-  \  }}||   j                  |       ||   j	                  |       / y)z*Make toolbar button tooltips translatable.r   z	Fit widthrC   zFit pagerE   zZoom outr   zZoom inrI   PortraitrK   	LandscaperN   z
First pagerP   zPrevious pagerR   z	Next pagerT   z	Last pagerW   zShow single pagerY   zShow overview of all pagesr[   z
Page setupr\   PrintN)r   r<   ra   setText
setToolTip)r   translatable_tooltipsra   idxtooltips        r   r>   z3SpyderPrintPreviewDialog.make_tooltips_translatableY   s   
 +**)*+<!?#$; ; %&'/01<!7!
" ,,&&(1 	-LCCL  )CL##G,	-r   c                 X    t         |   |       | j                  j                          y)z
        Give focus to the toolbar to avoid giving focus to the combobox that
        shows the page percentage size, which is odd.
        N)r:   	showEventr<   setFocus)r   eventrA   s     r   ro   z"SpyderPrintPreviewDialog.showEvents   s"    
 	% r   r   )	r2   r3   r4   __doc__r   r=   r>   ro   __classcell__)rA   s   @r   r8   r8   +   s"    
*/B-4   r   r8   )r   qtpy.QtCorer   
qtpy.QtGuir   qtpy.QtWidgetsr   qtpy.QtPrintSupportr   r   spyder.api.translationsr   spyder.utils.icon_managerr	   spyder.utils.stylesheetr
   r   r8   r6   r   r   <module>r{      s:       # = % ) <H .N 2 N r   