
    ը	fv]                         d Z ddlZddlmc mZ ddlmZ ddlm	Z	 ddl
mZ ddlmZmZmZmZmZ  G d de	      Z G d	 d
ej&                        Zy)a{  
@package gmodeler.preferences

@brief wxGUI Graphical Modeler - preferences

Classes:
 - preferences::PreferencesDialog
 - preferences::PropertiesDialog

(C) 2010-2013 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 Martin Landa <landa.martin gmail.com>
    N)	globalvar)PreferencesBaseDialog)UserSettings)SpinCtrlButton
StaticText	StaticBoxTextCtrlc                   R    e Zd ZdZe ed      fdZd Zd Zd Z	d Z
d Zd	 Zd
 Zy)PreferencesDialogzUser preferences dialogzModeler settingsc                    t        j                  | ||||       | j                  | j                         | j	                  | j                         | j                  | j                         | j                  | j                         | j                  | j                         | j                  | j                                | j                  | j                         y )N)parentgifacetitlesettings)r   __init___createGeneralPagenotebook_createActionPage_createDataPage_createLoopPage_createCommentPage
SetMinSizeGetBestSizeSetSizesize)selfr   r   r   r   s        5/usr/lib/grass83/gui/wxpython/gmodeler/preferences.pyr   zPreferencesDialog.__init__   s     	&&eh	

 	.t}}-T]]+T]]+.((*+TYY    c           	         t        j                  |t         j                        }|j                  |t	        d             t        j
                  t         j                        }t        |t         j                  dt	        d      z        }t        j                  |t         j                        }t        j                  dd      }d	}|j                  t        |t         j                  t	        d
            t         j                  t         j                  z  |d	f       t        j                  |t         j                  | j                   j#                  ddd      t$        j&                        }|j)                  d       |j+                         | j,                  d<   |j                  |t         j.                  t         j                  z  |df       |j1                  d	       |j                  |dt         j2                  t         j4                  z  d       |j                  |d	t         j6                  t         j8                  z  t         j:                  z  t         j4                  z  d       |j=                  |       |S )(Create notebook page for action settingsr   idGeneralpagetext %s zItem propertiesr   r#   label   hgapvgapr   z	Disabled:flagposmodelerdisabledcolorgroupkeysubkeyr   r#   colourr   	GetColourzmodeler:disabled:color      
proportionr0   border)wxPanelID_ANYAddPage_BoxSizerVERTICALr	   StaticBoxSizerGridBagSizerAddr   
ALIGN_LEFTALIGN_CENTER_VERTICALcselColourSelectr   Getr   DIALOG_COLOR_SIZESetNameGetIdwinIdALIGN_RIGHTAddGrowableColALLEXPANDLEFTRIGHTBOTTOMSetSizer)	r   r   panelr@   boxsizer	gridSizerrowrColors	            r   r   z$PreferencesDialog._createGeneralPage/   s   RYY7e!I,7 R[[)u&1EVCW:WX!!#r{{3OO3	e		;H!9!99a 	 	

 ""yy==$$9*W$U,,	
 	{#/5||~

+,"*B*BBa 	 	
 	  #		)0B1	M

288#bii/"));	 	 	
 	vr   c                 *   t        j                  |t         j                        }|j                  |t	        d             t        j
                  t         j                        }t        |t         j                  dt	        d      z        }t        j                  |t         j                        }t        j                  dd      }d	}|j                  t        |t         j                  t	        d
            t         j                  t         j                  z  |d	f       t        j                  |t         j                  | j                   j#                  ddd      t$        j&                        }|j)                  d       |j+                         | j,                  d<   |j                  |t         j.                  t         j                  z  |df       |dz  }|j                  t        |t         j                  t	        d            t         j                  t         j                  z  |d	f       t        j                  |t         j                  | j                   j#                  ddd      t$        j&                        }	|	j)                  d       |	j+                         | j,                  d<   |j                  |	t         j.                  t         j                  z  |df       |dz  }|j                  t        |t         j                  t	        d            t         j                  t         j                  z  |d	f       t        j                  |t         j                  | j                   j#                  ddd      t$        j&                        }
|
j)                  d       |
j+                         | j,                  d<   |j                  |
t         j.                  t         j                  z  |df       |j1                  d	       |j                  |dt         j2                  t         j4                  z  d       |j                  |d	t         j6                  t         j8                  z  t         j:                  z  t         j4                  z  d       t        |t         j                  dt	        d      z        }t        j                  |t         j                        }t        j                  dd      }d	}|j                  t        |t         j                  t	        d            t         j                  t         j                  z  |d	f       t=        |t         j                  d	d| j                   j#                  ddd             }|j)                  d!       |j+                         | j,                  d"<   |j                  |t         j.                  t         j                  z  |df       |dz  }|j                  t        |t         j                  t	        d#            t         j                  t         j                  z  |d	f       t=        |t         j                  d	d| j                   j#                  ddd$             }|j)                  d!       |j+                         | j,                  d%<   |j                  |t         j.                  t         j                  z  |df       |j1                  d	       |j                  |dt         j2                  t         j4                  z  d       |j                  |d	t         j6                  t         j8                  z  t         j:                  z  t         j4                  z  d       |j?                  |       |S )&r!   r"   Commandr%   r(   Colorr)   r+   r,   r   Valid:r/   r2   actionr4   validr5   r9   r;   zmodeler:action:color:validr<   zInvalid:)r4   invalidzmodeler:action:color:invalidzRunning:)r4   runningzmodeler:action:color:runningr=   r>   
Shape sizeWidth:  r   widthr   r#   minmaxinitialGetValuezmodeler:action:size:widthHeight:r   heightzmodeler:action:size:height rA   rB   rC   rD   rE   rF   rG   r	   rH   rI   rJ   r   rK   rL   rM   rN   r   rO   r   rP   rQ   rR   rS   rT   rU   rV   rW   rX   rY   rZ   r   r[   )r   r   r\   r@   r]   r^   r_   r`   vColoriColorra   ro   rw   s                r   r   z#PreferencesDialog._createActionPage[   s   RYY7e!I,7 R[[)u&1W::MN!!#r{{3OO3	e		8E!9!99a 	 	

 ""yy==$$X6H %  ,,
 	{#39<<>

/0"*B*BBa 	 	
 	qe		:G!9!99a 	 	

 ""yy==$$X6J %  ,,
 	{#5;\\^

12"*B*BBa 	 	
 	qe		:G!9!99a 	 	

 ""yy==$$X6J %  ,,
 	{#5;\\^

12"*B*BBa 	 	
 	  #		)0B1	M

288#bii/"));	 	 	
 u&1\?:RS!!#r{{3OO3	e		8E!9!99a 	 	
 yyMM%%X6G & 
 	j!27++-

./)A)AAQx 	 	
 	qe		9F!9!99a 	 	
 yyMM%%X6H & 
 	z"39<<>

/0"*B*BBa 	 	
 	  #		)0B1	M

288#bii/"));	 	 	
 	vr   c                 L   t        j                  |t         j                        }|j                  |t	        d             t        j
                  t         j                        }t        |t         j                  dt	        d      z        }t        j                  |t         j                        }t        j                  dd      }d	}|j                  t        |t         j                  t	        d
            t         j                  t         j                  z  |d	f       t        j                  |t         j                  | j                   j#                  ddd      t$        j&                        }|j)                  d       |j+                         | j,                  d<   |j                  |t         j.                  t         j                  z  |df       |dz  }|j                  t        |t         j                  t	        d            t         j                  t         j                  z  |d	f       t        j                  |t         j                  | j                   j#                  ddd      t$        j&                        }	|	j)                  d       |	j+                         | j,                  d<   |j                  |	t         j.                  t         j                  z  |df       |dz  }|j                  t        |t         j                  t	        d            t         j                  t         j                  z  |d	f       t        j                  |t         j                  | j                   j#                  ddd      t$        j&                        }
|
j)                  d       |
j+                         | j,                  d<   |j                  |
t         j.                  t         j                  z  |df       |dz  }|j                  t        |t         j                  t	        d            t         j                  t         j                  z  |d	f       t        j                  |t         j                  | j                   j#                  ddd      t$        j&                        }|j)                  d       |j+                         | j,                  d<   |j                  |t         j.                  t         j                  z  |df       |j1                  d	       |j                  |dt         j2                  t         j4                  z  d       |j                  |d	t         j6                  t         j8                  z  t         j:                  z  t         j4                  z  d       t        |t         j                  dt	        d      z        }t        j                  |t         j                        }t        j                  dd      }d	}|j                  t        |t         j                  t	        d             t         j                  t         j                  z  |d	f       t=        |t         j                  d	d!| j                   j#                  ddd"      #      }|j)                  d$       |j+                         | j,                  d%<   |j                  |t         j.                  t         j                  z  |df       |dz  }|j                  t        |t         j                  t	        d&            t         j                  t         j                  z  |d	f       t=        |t         j                  d	d!| j                   j#                  ddd'      #      }|j)                  d$       |j+                         | j,                  d(<   |j                  |t         j.                  t         j                  z  |df       |j1                  d	       |j                  |dt         j2                  t         j4                  z  d       |j                  |d	t         j6                  t         j8                  z  t         j:                  z  t         j4                  z  d       |j?                  |       |S ))z&Create notebook page for data settingsr"   Datar%   r(   Typer)   r+   r,   r   zRaster:r/   r2   data)r4   rasterr5   r9   r;   zmodeler:data:color:rasterr<   z
3D raster:)r4   raster3dzmodeler:data:color:raster3dzVector:)r4   vectorzmodeler:data:color:vectorzTable:)r4   dbtablezmodeler:data:color:dbtabler=   r>   rk   rl   rm   rn   rp   rt   zmodeler:data:size:widthru   rv   zmodeler:data:size:heightrx   )r   r   r\   r@   r]   r^   r_   r`   ra   r3Colorry   tColorro   rw   s                 r   r   z!PreferencesDialog._createDataPage   s   RYY7e!F)4 R[[)u&1V9:LM!!#r{{3OO3	e		9F!9!99a 	 	

 ""yy==$$V4G %  ,,
 	{#28,,.

./"*B*BBa 	 	
 	qe		<I!9!99a 	 	

 ##yy==$$V4I %  ,,
 	$4;MMO

01"..2+C+CC#q 	 	
 	qe		9F!9!99a 	 	

 ""yy==$$V4G %  ,,
 	{#28,,.

./"*B*BBa 	 	
 	qe		8E!9!99a 	 	

 ""yy==$$V4H %  ,,
 	{#39<<>

/0"*B*BBa 	 	
 	  #		)0B1	M

288#bii/"));	 	 	
 u&1\?:RS!!#r{{3OO3	e		8E!9!99a 	 	
 yyMM%%V4E & 
 	j!05

,-)A)AAQx 	 	
 	qe		9F!9!99a 	 	
 yyMM%%V4F & 
 	z"17

-."*B*BBa 	 	
 	  #		)0B1	M

288#bii/"));	 	 	
 	vr   c                 
   t        j                  |t         j                        }|j                  |t	        d             t        j
                  t         j                        }t        |t         j                  dt	        d      z        }t        j                  |t         j                        }t        j                  dd      }d	}|j                  t        |t         j                  t	        d
            t         j                  t         j                  z  |d	f       t        j                  |t         j                  | j                   j#                  ddd      t$        j&                        }|j)                  d       |j+                         | j,                  d<   |j                  |t         j.                  t         j                  z  |df       |j1                  d	       |j                  |dt         j2                  t         j4                  z  d       |j                  |d	t         j6                  t         j8                  z  t         j:                  z  t         j4                  z  d       t        |t         j                  dt	        d      z        }t        j                  |t         j                        }t        j                  dd      }d	}|j                  t        |t         j                  t	        d            t         j                  t         j                  z  |d	f       t=        |t         j                  d	d| j                   j#                  ddd            }	|	j)                  d       |	j+                         | j,                  d<   |j                  |	t         j.                  t         j                  z  |df       |dz  }|j                  t        |t         j                  t	        d            t         j                  t         j                  z  |d	f       t=        |t         j                  d	d| j                   j#                  ddd            }
|
j)                  d       |
j+                         | j,                  d<   |j                  |
t         j.                  t         j                  z  |df       |j1                  d	       |j                  |dt         j2                  t         j4                  z  d       |j                  |d	t         j6                  t         j8                  z  t         j:                  z  t         j4                  z  d       |j?                  |       |S ) z&Create notebook page for loop settingsr"   Loopr%   r(   rd   r)   r+   r,   r   re   r/   r2   looprg   r5   r9   r;   zmodeler:loop:color:validr<   r=   r>   rk   rl   rm   rn   rp   rt   zmodeler:loop:size:widthru   rv   zmodeler:loop:size:heightrx   r   r   r\   r@   r]   r^   r_   r`   ry   ro   rw   s              r   r   z!PreferencesDialog._createLoopPage  s'   RYY7e!F)4 R[[)u&1W::MN!!#r{{3OO3	e		8E!9!99a 	 	

 ""yy==$$V4F %  ,,
 	{#17

-."*B*BBa 	 	
 	  #		)0B1	M

288#bii/"));	 	 	
 u&1\?:RS!!#r{{3OO3	e		8E!9!99a 	 	
 yyMM%%V4E & 
 	j!05

,-)A)AAQx 	 	
 	qe		9F!9!99a 	 	
 yyMM%%V4F & 
 	z"17

-."*B*BBa 	 	
 	  #		)0B1	M

288#bii/"));	 	 	
 	vr   c                 
   t        j                  |t         j                        }|j                  |t	        d             t        j
                  t         j                        }t        |t         j                  dt	        d      z        }t        j                  |t         j                        }t        j                  dd      }d	}|j                  t        |t         j                  t	        d
            t         j                  t         j                  z  |d	f       t        j                  |t         j                  | j                   j#                  ddd      t$        j&                        }|j)                  d       |j+                         | j,                  d<   |j                  |t         j.                  t         j                  z  |df       |j1                  d	       |j                  |dt         j2                  t         j4                  z  d       |j                  |d	t         j6                  t         j8                  z  t         j:                  z  t         j4                  z  d       t        |t         j                  dt	        d      z        }t        j                  |t         j                        }t        j                  dd      }d	}|j                  t        |t         j                  t	        d            t         j                  t         j                  z  |d	f       t=        |t         j                  d	d| j                   j#                  ddd            }	|	j)                  d       |	j+                         | j,                  d<   |j                  |	t         j.                  t         j                  z  |df       |dz  }|j                  t        |t         j                  t	        d            t         j                  t         j                  z  |d	f       t=        |t         j                  d	d| j                   j#                  ddd            }
|
j)                  d       |
j+                         | j,                  d<   |j                  |
t         j.                  t         j                  z  |df       |j1                  d	       |j                  |dt         j2                  t         j4                  z  d       |j                  |d	t         j6                  t         j8                  z  t         j:                  z  t         j4                  z  d       |j?                  |       |S ) z)Create notebook page for comment settingsr"   Commentr%   r(   rd   r)   r+   r,   r   re   r/   r2   commentr4   r5   r9   r;   zmodeler:comment:colorr<   r=   r>   rk   rl   rm   rn   rp   rt   zmodeler:comment:size:widthru   rv   zmodeler:comment:size:heightrx   r   s              r   r   z$PreferencesDialog._createCommentPage  s   RYY7e!I,7 R[[)u&1W::MN!!#r{{3OO3	e		8E!9!99a 	 	

 ""yy==$$9)G$T,,	
 	{#.4lln

*+"*B*BBa 	 	
 	  #		)0B1	M

288#bii/"));	 	 	
 u&1\?:RS!!#r{{3OO3	e		8E!9!99a 	 	
 yyMM%%Y7H & 
 	j!38;;=

/0)A)AAQx 	 	
 	qe		9F!9!99a 	 	
 yyMM%%Y7I & 
 	z"4:LLN

01"*B*BBa 	 	
 	  #		)0B1	M

288#bii/"));	 	 	
 	vr   c                     t        j                  | |       | j                  j                         j	                          | j                  j                         j                          y)zButton 'Apply' pressedN)r   OnApplyr   GetModelUpdate	GetCanvasRefreshr   events     r   r   zPreferencesDialog.OnApplyn  sD    %%dE2%%''')r   c                     t        j                  | |       | j                  j                         j	                          | j                  j                         j                          y)zButton 'Save' pressedN)r   OnSaver   r   r   r   r   r   s     r   r   zPreferencesDialog.OnSaveu  sD    $$T51%%''')r   N)__name__
__module____qualname____doc__r   rE   r   r   r   r   r   r   r   r    r   r   r   r      sC    ! (41=O;P "*XSjhTiVgR**r   r   c                       e Zd ZdZej
                   ed      dej                  ej                  z  fdZ	d Z
d Zd Zd Zy	)
PropertiesDialogzModel properties dialogzModel properties)i^  i  c                    t         j                  j                  | |||||       t        | t         j                  dt        d      z        | _        t        | t         j                  dt        d      z        | _        t        | t         j                  d      | _	        t        | t         j                  t         j                  d	      | _        t        | t         j                  d      | _        t        j                  | t         j                  t        d
            | _        | j                  j                  t!        j"                  ddd             t%        | t         j&                        | _        t%        | t         j*                        | _        | j(                  j/                          | j(                  j1                  t        d             | j(                  j/                          | j,                  j1                  t        d             | j3                  t         j4                  | j6                         | j9                          y )N)r   styler(   Metadatar)   Commands),     )r   r#   r   )r   2   )r   r#   r   r   z.Allow output files to overwrite existing filescmd	overwriteenabledr5   zApply propertieszClose dialog and ignore changes)rA   Dialogr   r	   rC   rE   metaBoxcmdBoxr
   nameTE_MULTILINEdescauthorCheckBoxr   SetValuer   rO   r   ID_OKbtnOk	ID_CANCEL	btnCancel
SetDefault
SetToolTipBind	EVT_CLOSEOnCloseWindow_layout)r   r   r#   r   r   r   s         r   r   zPropertiesDialog.__init__  s    			4UUK BIIVa
m-C
  t		!J-AWXDRYYYG	BIIR__9
	 dryyyI yyDE

 	5k)L	

 D"((+
bll3



a 234

!!!$E"FG		",, 2 23r   c           	      ~   t        j                  | j                  t         j                        }t        j                  dd      }|j                  t        | t         j                  t        d            t         j                  t         j                  z  d       |j                  | j                  t         j                  t         j                  z  t         j                  z  d       |j                  t        | t         j                  t        d            t         j                  t         j                  z  d	       |j                  | j                  t         j                  t         j                  z  t         j                  z  d
       |j                  t        | t         j                  t        d            t         j                  t         j                  z  d       |j                  | j                  t         j                  t         j                  z  t         j                  z  d       |j                  d       |j!                  d       |j                  |dt         j                         t        j                  | j"                  t         j                        }|j                  | j$                  t         j                  t         j&                  z  d       t        j(                         }|j+                  | j,                         |j+                  | j.                         |j1                          t        j2                  t         j                        }|j                  |dt         j                  t         j&                  z  d       |j                  |dt         j                  t         j4                  z  t         j6                  z  t         j8                  z  d       |j                  |dt         j                  t         j&                  z  d       | j;                  |       |j=                  |        y )Nr+   r,   zName:r)   )r   r   r/   )r   r<   zDescription:)r<   r   )r<   r<   z
Author(s):)   r   )r   r<   r<   )r?   r0   )r0   r@   r=   r>   r   )rA   rH   r   rG   rI   rJ   r   rC   rE   rK   rL   r   rW   r   r   rU   AddGrowableRowr   r   rV   StdDialogButtonSizer	AddButtonr   r   RealizerF   rX   rY   rZ   r[   Fit)r   	metaSizerr_   cmdSizerbtnStdSizer	mainSizers         r   r   zPropertiesDialog._layout  s   %%dllBKK@	OO3	dryy'
C!9!99 	 	

 	II!9!99BIIE 	 	

 	dryy.8IJ!9!99 	 	

 	II!9!99BIIE 	 	

 	dryy,H!9!99 	 	

 	KK!9!99BIIE 	 	

 	  #  #iABII>$$T[["++>T^^"))bff*<QG--/dnn-djj)KK,	iABII4FqQRWW$rxx/"));	 	 	
 	kabii"&&6HQRSi dr   c                 $    | j                          y )N)Hider   s     r   r   zPropertiesDialog.OnCloseWindow  s    		r   c                     | j                   j                         | j                  j                         | j                  j                         | j                  j                         dS )z
Get values)r   descriptionr   r   )r   rt   r   r   r   	IsChecked)r   s    r   	GetValueszPropertiesDialog.GetValues  sN     II&&(99--/kk**,113	
 	
r   c                     | j                   j                  |d          | j                  j                  |d          | j                  j                  |d          d|v r| j                  j                  |d          yy)zInitialize dialogr   r   r   r   N)r   r   r   r   r   )r   props     r   InitzPropertiesDialog.Init  si    		4<(		4./T(^,$NN##D$56 r   N)r   r   r   r   rA   rC   rE   DEFAULT_DIALOG_STYLERESIZE_BORDERr   r   r   r   r   r   r   r   r   r   }  sI    !
 99"#%%(8(88*X8t
7r   r   )r   rA   wx.lib.colourselectlibcolourselectrM   corer   gui_core.preferencesr   core.settingsr   gui_core.wrapr   r   r   r	   r
   r   r   r   r   r   r   <module>r      sF   " 
 " "  6 & K K_	*- _	*D{7ryy {7r   