
    ը	f                     p    d Z ddlZddlmZ  G d dej                        Z G d dej                        Zy)a  
@package mapdisp.gprint

@brief Print context and utility functions for printing
contents of map display window.

Classes:
 - gprint::MapPrint
 - gprint::PrintOptions

(C) 2007-2011 by the GRASS Development Team

This program is free software under the GNU General Public License
(>=v2). Read the file COPYING that comes with GRASS for details.

@author Michael Barton (Arizona State University)
    N)GMessagec                   ^     e Zd Zd Z fdZ fdZ fdZ fdZ fdZd Z	d Z
d	 Z xZS )
MapPrintc                 P    t         j                  j                  |        || _        y N)wxPrintout__init__canvas)selfr   s     //usr/lib/grass83/gui/wxpython/mapdisp/gprint.pyr
   zMapPrint.__init__   s    
T"    c                 ,    t         t        |   ||      S r   )superr   OnBeginDocument)r   startend	__class__s      r   r   zMapPrint.OnBeginDocument   s    Xt4UC@@r   c                 *    t         t        |           y r   )r   r   OnEndDocumentr   r   s    r   r   zMapPrint.OnEndDocument        h+-r   c                 *    t         t        |           y r   )r   r   OnBeginPrintingr   s    r   r   zMapPrint.OnBeginPrinting#   s    h-/r   c                 *    t         t        |           y r   )r   r   OnEndPrintingr   s    r   r   zMapPrint.OnEndPrinting&   r   r   c                 *    t         t        |           y r   )r   r   OnPreparePrintingr   s    r   r   zMapPrint.OnPreparePrinting)   s    h/1r   c                     |dk  ryy)N   TF )r   pages     r   HasPagezMapPrint.HasPage,   s    19r   c                      y)N)   r    r%   r    r!   r   s    r   GetPageInfozMapPrint.GetPageInfo2   s    r   c                 J   | j                         }| j                  j                         \  }}d}d}|d|z  z   }|d|z  z   }|j                         \  }}t	        |      |z  }	t	        |      |z  }
t        |	|
      }|| j                  j                         d   |z  z
  dz  }|| j                  j                         d   |z  z
  dz  }|j                  ||       |j                  t        |      t        |             | j                  j                  j                  |       y)N
   r    r   g       @r%   T)GetDCr   GetSizeGetSizeTuplefloatminSetUserScaleSetDeviceOriginintpdcDrawToDC)r   r"   dcmaxXmaxYmarginXmarginYwhscaleXscaleYactualScaleposXposYs                 r   OnPrintPagezMapPrint.OnPrintPage5   s   ZZ\ [[((*
d  q7{#q7{# "A qDqD &&) T[[((*1-;<CT[[((*1-;<C 	[1
3t9c$i0 	  $
 r   )__name__
__module____qualname__r
   r   r   r   r   r   r#   r'   r@   __classcell__)r   s   @r   r   r      s1    A.0.2(r   r   c                   *    e Zd Zd Zd Zd Zd Zd Zy)PrintOptionsc                 .    || _         || _        d | _        y r   )mapframemapwin	printData)r   parentrI   s      r   r
   zPrintOptions.__init__a   s    r   c                     | j                   ry t        j                         | _         | j                   j                  t        j                         | j                   j                  t        j                         y r   )rJ   r   	PrintData
SetPaperIdPAPER_LETTERSetPrintModePRINT_MODE_PRINTERr&   s    r   setupzPrintOptions.setupg   sG    >>!!"//2##B$9$9:r   c                 n   | j                          t        j                  | j                        }|j	                          t        j
                  | j                  |      }|j                          t        j                  |j                         j                               | _        |j                          y r   )rR   r   PageSetupDialogDatarJ   CalculatePaperSizeFromIdPageSetupDialogrI   	ShowModalrM   GetPageSetupDataGetPrintDataDestroy)r   eventpsdddlgs       r   OnPageSetupzPrintOptions.OnPageSetupn   sw    

%%dnn5%%'  d3
 c&:&:&<&I&I&KLr   c                    | j                          t        j                  | j                        }t	        | j
                        }t	        | j
                        }t        j                  |||      | _        | j                  j                         s%t        j                  dt        j                         y t        j                  | j                  | j                  d      }|j                          |j                  | j                  j                                |j!                  | j                  j#                                |j%                  d       y )Nz*There was a problem printing this display
zPrint previewT)rR   r   PrintDialogDatarJ   r   rI   PrintPreviewpreviewOk
MessageBoxOKPreviewFramerH   
InitializeSetPositionGetPositionSetSizeGetClientSizeShow)r   r[   dataprintout	printout2pfrms         r   OnPrintPreviewzPrintOptions.OnPrintPreview|   s    

!!$..1DKK(T[[)	xDA|| MMGOt||T]]OL2245T]]0023		$r   c                    | j                          t        j                  | j                        }|j	                  d       t        j
                  |      }t        | j                        }|j                  | j                  |d      st        t        d             n6t        j                  |j                         j                               | _        |j                          y )Nr%   TzPThere was a problem printing.
Perhaps your current printer is not set correctly?)rR   r   r`   rJ   	SetToPagePrinterr   rI   PrintrH   r   _rM   GetPrintDialogDatarY   rZ   )r   r[   pddprinterrn   s        r   	OnDoPrintzPrintOptions.OnDoPrint   s    

  0a**S/DKK(}}T]]Hd;I  \\'*D*D*F*S*S*UVDNr   N)rA   rB   rC   r
   rR   r^   rq   rz   r!   r   r   rF   rF   `   s    ;$r   rF   )__doc__r   	core.gcmdr   r	   r   ObjectrF   r!   r   r   <module>r~      s5   $ 
 Er{{ EP?299 ?r   