EnglishРусский  

   ..

   addustr.g

   app.g

   btn.g

   btnpic.g

   comp.g

   ctrl.g

   dialogs.g

   edit.g

   events.g

   fonts.g

   form.g

   gray.g

   grey.g

   images.g

   label.g

   labeled.g

   locustr.g

   menu.g

   panel.g

   picture.g

   s.txt

   styles.g

   tab.g

   tabitem.g

   tabpage.g

   toolbar.g

   tray.g

   url.g

   vis.g

   viswin.g

Ads

Perfect Automation tool
All-In-One: Script editor, Launcher, Scheduler, Keyboard & Mouse Recorder. Try now!

CreateInstall
Freeware and commercial installers.

Cell Phone Batteries
Batteries Plus offers batteries for laptop, camcorder, cell phone, camera.

Gentee needs your help!
How to advertise with us
 
laptop battery

source\lib\vis\url.g
  1 /******************************************************************************
  2 *
  3 * Copyright (C) 2004-2007, The Gentee Group. All rights reserved. 
  4 * This file is part of the Gentee open source project - http://www.gentee.com. 
  5 * 
  6 * THIS FILE IS PROVIDED UNDER THE TERMS OF THE GENTEE LICENSE ("AGREEMENT"). 
  7 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE CONSTITUTES RECIPIENTS 
  8 * ACCEPTANCE OF THE AGREEMENT.
  9 *
 10 * ID: vis.url 05.02.08 0.0.A.
 11 *
 12 * Author: Alexander Krivonogov ( gentee )
 13 *
 14 ******************************************************************************/
 15 /* Компонента vURL, порождена от vCtrl
 16 События   
 17 */
 18 type vURL <inherit = vCtrl>
 19 {
 20 //Hidden fields
 21    locustr  pCaption    
 22    locustr  pURL
 23    uint     pColorUnvis 
 24    uint     pColorVis
 25    uint     flgVisited
 26    uint     flgClick
 27    uint     hFontUnderline   
 28    
 29 //Events   
 30    evEvent   OnClick   
 31 }
 32 
 33 extern {
 34    method vURL.mFontChanged ()
 35 }
 36 
 37 
 38 /*------------------------------------------------------------------------------
 39    Internal Methods
 40 */
 41 method locustr vURL.iCurCaption()
 42 {
 43    if *.pCaption.Value
 44    {
 45       return .pCaption 
 46    }
 47    else
 48    {  
 49       return .pURL
 50    }
 51 }
 52 
 53 method uint vURL.iCurCaptionPtr()
 54 { 
 55 //   print( "getcur \(.pCaption.Text(this).ptr())\n" )
 56 //return .pCaption.Text(this).ptr()
 57    if *.pCaption.Value//Text(this)
 58    {
 59       return .pCaption.Text(this).ptr() 
 60    }
 61    else
 62    {  
 63       return .pURL.Text(this).ptr()
 64    }
 65 }
 66 
 67 method uint vURL.iCurCaptionLen()
 68 {
 69    //uint lencaption
 70    if *.pCaption.Value//lencaption = *.pCaption.Text(this)
 71    {
 72       return *.pCaption.Text(this)//lencaption
 73    }   
 74    return *.pURL.Text(this)
 75    
 76 }
 77 
 78 method vURL.iUpdateSize()
 79 {
 80    RECT r
 81    uint dc = GetDC( 0 )      
 82    r.right = .clloc.width
 83    r.bottom = .clloc.height      
 84    SelectObject( dc, this.hFontUnderline )
 85    uint curcaption as .iCurCaption()   
 86    DrawText( dc, curcaption.Text(this).ptr(), *curcaption.Text(this), r, $DT_SINGLELINE | $DT_CALCRECT )      
 87    ReleaseDC( 0, dc )
 88    .Width = r.right
 89    .Height = r.bottom
 90    //print( "updateurl \(.Name) \(.Width )\n" )
 91    InvalidateRect( this.hwnd, 0->RECT, 1 )
 92 }
 93 /*------------------------------------------------------------------------------
 94    Properties
 95 */
 96 /* Свойство str vURL.Caption - Get Set
 97 Усотанавливает или получает заколовок ссылки
 98 */
 99 property ustr vURL.Caption <result>
100 {
101    result = this.pCaption.Value
102 }
103 
104 property vURL.Caption( ustr val )
105 {
106    if val != this.pCaption.Value
107    {       
108       this.pCaption.Value = val     
109       .iUpdateSize()      
110    } 
111 }
112 
113 /* Свойство str vURL.URL - Get Set
114 Усотанавливает или получает строку запуска
115 */
116 property ustr vURL.URL <result>
117 {
118    result = this.pURL.Value
119 }
120 
121 property vURL.URL( ustr val )
122 {
123    if val != this.pURL.Value
124    {  
125       this.pURL.Value = val   
126       .iUpdateSize()   
127    } 
128 }
129 
130 /*------------------------------------------------------------------------------
131    Windows messages
132 */
133 /*Обработка WM_PAINT - отрисовка ссылки
134 */
135 method uint vURL.wmpaint <alias=vURL_wmpaint>(winmsg wmsg)
136 {
137    uint hdc
138    PAINTSTRUCT lp   
139    hdc = BeginPaint( this.hwnd, lp )
140    
141    RECT r
142    r.left = 0
143    r.top = 0
144    r.right = this.loc.width
145    r.bottom = this.loc.height  
146    if isThemed 
147    {
148       pDrawThemeParentBackground->stdcall( this.hwnd, hdc, 0 );
149    }
150    SetTextColor( hdc, ?(.flgVisited, .pColorVis, .pColorUnvis ))
151    SetBkMode( hdc, $TRANSPARENT )      
152    uint curcaption as .iCurCaption()
153    
154    SelectObject( hdc, .hFontUnderline )   
155    DrawText( hdc, curcaption.Text(this).ptr(), *curcaption.Text(this), r, $DT_LEFT | $DT_SINGLELINE | $DT_VCENTER )                       
156    EndPaint( this.hwnd, lp )
157    //wmsg.flags = 1
158 	return 1	   
159 }
160 
161 /*------------------------------------------------------------------------------
162    Virtual methods
163 */
164 /*Виртуальный метод vURL.mSetName - Установка заголовка в режиме проектирования
165 */
166 method uint vURL.mSetName <alias=vURL_mSetName>( str newname )
167 {
168 ifdef $DESIGNING {   
169    if !.p_loading && .Caption == .Name
170    {
171       .Caption = newname.ustr()
172    }
173 }   
174    return 1 
175 }
176 
177 /*Виртуальный метод vURL.mMouse - События от мыши
178 */
179 method uint vURL.mMouse <alias=vURL_mMouse>( evparMouse em )
180 {
181    if em.evmtype == $evmLDown
182    {   
183       SetCapture( .hwnd )
184       .flgClick = 1
185    }
186    elif em.evmtype == $evmLUp
187    {         
188       ReleaseCapture()
189       if .flgClick 
190       {  
191          .flgClick = 0
192          .flgVisited = 1
193          POINT pt
194          RECT rect      
195          GetCursorPos( pt ) 
196          GetWindowRect( .hwnd, rect )
197          if PtInRect( rect, pt.x, pt.y )         
198          {
199             evparEvent ev
200             ev.sender = &this
201             .OnClick.run( ev )
202             if *.pURL.Text(this)
203             {
204                shell( .pURL.Text(this).str() )
205             }
206             InvalidateRect( .hwnd, 0->RECT, 1 )            
207          }
208       }
209    }   
210    return 1 
211 }
212 
213 /*Виртуальный метод vURL vURL.mCreateWin - Создание окна
214 */
215 method vURL vURL.mCreateWin <alias=vURL_mCreateWin>()
216 {
217    .CreateWin( "GVUrl".ustr(), 0,$WS_VISIBLE | $WS_CHILD | $WS_CLIPSIBLINGS )
218    this.prevwndproc = -1   
219    this->vCtrl.mCreateWin()   
220    .mFontChanged()
221      
222    return this
223 }
224 
225 /*Виртуальный метод vURL vURL.mDestroyWin - Удаление окна
226 */
227 method vURL.mDestroyWin <alias=vURL_mDestroyWin> ()
228 {
229    this->vCtrl.mDestroyWin()
230    DeleteObject( .hFontUnderline )
231 }
232 
233 /*Виртуальный метод vURL vURL.mFontChanged - изменение шрифта окна
234 */
235 method vURL.mFontChanged <alias=vURL_mFontChanged> ()
236 {
237    this->vCtrl.mFontChanged()   
238    LOGFONT lf 
239    GetObject( .hFont, sizeof( LOGFONT ), &lf)
240    lf.lfUnderline=1   
241    .hFontUnderline = CreateFontIndirect( lf )   
242    .iUpdateSize()
243 }
244 
245 /*Виртуальный метод uint vURL.mLangChanged - Изменение текущего языка
246 */
247 method vURL.mLangChanged <alias=vURL_mLangChanged>()
248 {   
249    .iUpdateSize()
250 }
251 
252 /*------------------------------------------------------------------------------
253    Registration
254 */
255 method vURL vURL.init( )
256 {
257    this.pTypeId = vURL
258    //this.flgRePaint = 1
259    this.loc.width = 100
260    this.loc.height = 100
261    this.pColorVis = 0x800080
262    this.pColorUnvis = 0xFF0000
263    return this 
264 }  
265 
266 func init_vURL <entry>()
267 {  
268    WNDCLASSEX visclass
269    ustr classname = "GVUrl"    
270    with visclass
271    {
272       .cbSize      = sizeof( WNDCLASSEX )
273       .lpfnWndProc = callback( &myproc, 4 )
274       .hInstance   = GetModuleHandle( 0 )
275       .hCursor     = LoadCursor( 0, $IDC_HAND )
276       .hbrBackground = 16
277       .lpszClassName = classname.ptr()
278    } 
279    uint hclass = RegisterClassEx( &visclass )
280    
281    regcomp( vURL, "vURL", vCtrl, $vCtrl_last,
282       %{ %{$mCreateWin,   vURL_mCreateWin },
283          %{$mSetName,     vURL_mSetName },
284          %{$mMouse,       vURL_mMouse },
285          %{$mFontChanged, vURL_mFontChanged },
286          %{$mLangChanged, vURL_mLangChanged }
287       },
288       %{ %{ $WM_PAINT, vURL_wmpaint }} )
289 
290 ifdef $DESIGNING {      
291    cm.AddComp( vURL, 1, "Additional", "url" )
292    
293    cm.AddProps( vURL, %{
294 "Caption"      , ustr, $PROP_LOADAFTERCHILD,
295 "URL"          , ustr, $PROP_LOADAFTERCHILD
296    })
297    
298    cm.AddEvents( vURL, %{
299 "OnClick"      , "evparEvent"
300    })
301 }
302 }
Edit