galería de imágenes

Re: galería de imágenes

Postby Antonio Linares » Sat Jan 16, 2021 7:47 am

José Luis,

Add this new DATA in Class TAlbum:

DATA lExit INIT .F.

and modify this method this way:

Code: Select all  Expand view
METHOD Activate() CLASS TAlbum

   ::CreateWindow()
   ::CreateControls()
   ::SetVScroll()
   ::oWnd:bResized := { |t,w,h| ::Resize( t, w, h ) }

   if ::oWnd:IsKindOf( "MDICHILD" )
      ACTIVATE WINDOW ::oWnd VALID ::lExit := .T.
   else
      ACTIVATE WINDOW ::oWnd CENTERED VALID  ::lExit := .T.
   endif

   StopUntil( { || ::lExit } )

return Self
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41323
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: galería de imágenes

Postby José Luis Sánchez » Sat Jan 16, 2021 3:08 pm

Antonio,

your code works fine, I've made a small sample with a mail window calling the talbum and the window remains on the top of the main window. In my program it doesn't work, I don't know why, it's very strange.

I want to create a control based on talbum so I can create a dialog with the album and other controls. I've never done a control, my friend Paco was who created them, but I think I can do it.

My goal is to create something like the Plex interface, like in this image.

Image

In Plex, the slider on the top right changes the size of the thumbnails, this is a feature I'd like to achieve.

I'll post in this threat any advance in the control. If someone wants to help me please contact me.

Kind regards,
José Luis
User avatar
José Luis Sánchez
 
Posts: 539
Joined: Thu Oct 13, 2005 9:23 am
Location: Novelda - Alicante - España

Re: galería de imágenes

Postby nageswaragunupudi » Sun Jan 17, 2021 12:17 pm

Can you see if MDI application suits you?

Please try this and let us have your response.
Code: Select all  Expand view
function Main()

   local oWnd, oBar
   local aImages := nil

   DEFINE WINDOW oWnd MDI
   DEFINE BUTTONBAR oBar OF oWnd SIZE 100,32 2007
   DEFINE BUTTON OF oBar PROMPT "Album" CENTER ACTION ;
      ( aImages  := ImageArray(), TAlbum():New( aImages ):Activate() )

   ACTIVATE WINDOW oWnd CENTERED

return nil
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10254
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: galería de imágenes

Postby nageswaragunupudi » Sun Jan 17, 2021 3:39 pm

Sorry, I did not see the above two postings.
Nice.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10254
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: galería de imágenes

Postby Antonio Linares » Sun Jan 17, 2021 5:43 pm

José Luis,

Is your main window MDI ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41323
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: galería de imágenes

Postby José Luis Sánchez » Sun Jan 17, 2021 6:15 pm

Antonio, I use TFSDI https://www.alanit.com/2006/06/fsdi2006/ that is a dialog overlaped the main window. In the link you can download a sample.

Regards,
User avatar
José Luis Sánchez
 
Posts: 539
Joined: Thu Oct 13, 2005 9:23 am
Location: Novelda - Alicante - España

Re: galería de imágenes

Postby José Luis Sánchez » Sun Jan 17, 2021 6:28 pm

I noticed that the INIT clause doesn't assign .F. to lExit so I changed the code:
Code: Select all  Expand view

METHOD Activate() CLASS TAlbum
   local hWndMain
   ::CreateWindow()
   ::CreateControls()
   ::SetVScroll()
   ::oWnd:bResized := { |t,w,h| ::Resize( t, w, h ) }
   ::lExit := .F.

   ACTIVATE WINDOW ::oWnd CENTERED ;
      VALID (::lExit := .t.) // ON INIT ( ::oWnd:Center( oApp():oWndMain ) )

   StopUntil( { || ::lExit  } )
   
return Self


and then it runs ok. I have this in mind for several years, look at this https://www.alanit.com/2008/03/libra/.

I will try to create a control with Mr. Rao class, but for me it is fully usable.

Thank you very much to both of you.

Kind regards,
User avatar
José Luis Sánchez
 
Posts: 539
Joined: Thu Oct 13, 2005 9:23 am
Location: Novelda - Alicante - España

Re: galería de imágenes

Postby Antonio Linares » Mon Jan 18, 2021 7:49 am

José Luis,

Using DATA lExit INIT .F. automatically initializes it to .F.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41323
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: galería de imágenes

Postby Antonio Linares » Mon Jan 18, 2021 11:48 am

José Luis,

A first try implementing Class TAlbum as a control:

Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

   local oDlg, oAlbum

   DEFINE DIALOG oDlg SIZE 1250, 800

   oAlbum = TAlbum():New( 0, 0, 1200, 800, oDlg )

   ACTIVATE DIALOG oDlg CENTERED ;
      ON INIT ( oAlbum:SetSize( 1250, 800 ),;
                oAlbum:LoadImages( ASize( DirectoryRecurse( "c:\fwh\bitmaps\*.*" ), 8 ) ) )

return nil

CLASS TAlbum FROM TPanel

   CLASSDATA lRegistered INIT .F.

   DATA   aPhotos    INIT  {}
   DATA   nImgWidth  INIT 210
   DATA   nImgHeight INIT 300
   DATA   nGutter    INIT  30

   METHOD AddImage( cImage )

   METHOD DefControl( oCtrl )  
     
   METHOD Initiate( hDlg )  

   METHOD LoadImages( aImages )

ENDCLASS

METHOD DefControl( oCtrl ) CLASS TAlbum
   
   DEFAULT oCtrl:nId := oCtrl:GetNewId()

   if AScan( ::aControls, { | o | o:nId == oCtrl:nId } ) > 0
      #define DUPLICATED_CONTROLID  2
      Eval( ErrorBlock(), _FWGenError( DUPLICATED_CONTROLID, ;
                          "No: " + Str( oCtrl:nId, 6 ) ) )
   else
      AAdd( ::aControls, oCtrl )
      oCtrl:hWnd = 0
   endif

return nil  

METHOD Initiate( hDlg ) CLASS TAlbum

   local aPhoto

   if ::oWnd:IsKindOf( "TDIALOG" )
      ::Super:Initiate( hDlg )
   endif

return nil

METHOD AddImage( cImage ) CLASS TAlbum

   local oImg, nCols := Int( ::nWidth / ::nImgWidth )
   local nRows := Int( ::nHeight / ::nImgHeight )
   local nRow := Int( Len( ::aControls ) / ( nRows * nCols ) + 0.5 )
   local nCol := Len( ::aControls ) - ( nRow * nCols )

   // MsgInfo( nRow )
   // MsgInfo( nCol )

   AAdd( ::aPhotos, cImage )

   @ ::nGutter + ( ::nImgHeight + ::nGutter ) * nRow,;
     ::nGutter + ( ::nImgWidth + ::nGutter ) * nCol;
     XIMAGE oImg OF Self ;
     SIZE ::nImgWidth, ::nImgHeight // NOBORDER

   oImg:SetSource( cImage )
   oImg:Shadow()

return nil  

METHOD LoadImages( aImages ) CLASS TAlbum

   ::aPhotos = aImages
   AEval( ::aPhotos, { | aPhoto | ::AddImage( aPhoto[ 1 ] ) } )

return nil
 
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41323
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: galería de imágenes

Postby José Luis Sánchez » Mon Jan 18, 2021 5:29 pm

Thanks Antonio, the dialog version works fine, but doesn't has the scroll feature.

Regards,
User avatar
José Luis Sánchez
 
Posts: 539
Joined: Thu Oct 13, 2005 9:23 am
Location: Novelda - Alicante - España

Re: galería de imágenes

Postby José Luis Sánchez » Mon Jan 18, 2021 6:28 pm

About centering the TAlbum over the main window of my program, I do the following:

Code: Select all  Expand view
  ACTIVATE WINDOW ::oWnd ;
      ON INIT ::oWnd:Center( oApp():oWndMain ) ;
      VALID (::lExit := .t.)


and I get this error:
Application
===========
Path and name: C:\alanit\develop\bitacora\bitacora.exe (32 bits)
Size: 5,786,624 bytes
Compiler version: Harbour 3.2.0dev (r1904111533)
FiveWin version: FWH 19.05
C compiler version: Borland/Embarcadero C++ 7.0 (32-bit)
Windows version: 6.2, Build 9200

Time from start: 0 hours 0 mins 4 secs
Error occurred at: 18-01-2021, 19:22:23
Error description: Error BASE/1004 No existe el m‚todo: CENTER
Args:
[ 1] = U
[ 2] = O TWINDOW

Stack Calls
===========
Called from: ..\contrib\hbct\ctmisc.prg => CENTER( 0 )
Called from: .\prg\fwh\TALBUM.PRG => (b)TALBUM_ACTIVATE( 96 )

I don't know what has hbct to do in this. In my .bc file I have:

bitacora.exe, +
bitacora.map, +
c:\fivetech\fwh1905\lib\filexls.lib +
c:\fivetech\fwh1905\lib\FiveH.lib +
c:\fivetech\fwh1905\lib\FiveHC.lib +

and some lines after I link hbct.

Regards,
User avatar
José Luis Sánchez
 
Posts: 539
Joined: Thu Oct 13, 2005 9:23 am
Location: Novelda - Alicante - España

Re: galería de imágenes

Postby Antonio Linares » Tue Jan 19, 2021 9:48 am

José Luis,

It seems as ::oWnd hasn't been assigned previously

Error description: Error BASE/1004 No existe el m‚todo: CENTER
Args:
[ 1] = U

That means that ::oWnd is nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41323
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: galería de imágenes

Postby José Luis Sánchez » Tue Jan 19, 2021 3:33 pm

I don't undestand this. I'm using the same code from Mr. Rao. If I write:

Code: Select all  Expand view
 oAlbum := TAlbum():New():Activate()


I don't have the error, but if I write

Code: Select all  Expand view
oAlbum := TAlbum():New()
oAlbum:Activate()


I get the error.
User avatar
José Luis Sánchez
 
Posts: 539
Joined: Thu Oct 13, 2005 9:23 am
Location: Novelda - Alicante - España

Re: galería de imágenes

Postby José Luis Sánchez » Tue Jan 19, 2021 3:35 pm

Mr. Rao,

it's possible to add a method to select a image and highlight it and then with arrow keys move and select other image ?

Regards,
User avatar
José Luis Sánchez
 
Posts: 539
Joined: Thu Oct 13, 2005 9:23 am
Location: Novelda - Alicante - España

Re: galería de imágenes

Postby Antonio Linares » Tue Jan 19, 2021 4:18 pm

José Luis Sánchez wrote:I don't undestand this. I'm using the same code from Mr. Rao. If I write:

Code: Select all  Expand view
 oAlbum := TAlbum():New():Activate()


I don't have the error, but if I write

Code: Select all  Expand view
oAlbum := TAlbum():New()
oAlbum:Activate()


I get the error.


José Luis,

Please post the error.log here, thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41323
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

PreviousNext

Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 11 guests