hmg extend com oop

Projeto MiniGui - Biblioteca visual para Harbour/xHarbour

Moderador: Moderadores

ivanil
Usuário Nível 3
Usuário Nível 3
Mensagens: 166
Registrado em: 11 Set 2004 15:13
Localização: Florianópolis/SC

hmg extend com oop

Mensagem por ivanil »

veja em funcionamento;
Anexos
teste.png
Avatar do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20267
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP

hmg extend com oop

Mensagem por JoséQuintas »

A criação aqui, nem é a parte importante.
Talvez o uso de variáveis LOCAIS

Código: Selecionar todos

PROCEDURE Main

   LOCAL oMain, oFrame1, oLabel1, oProgbar1, oButton1, oButton2, oButton3
   LOCAL oButton31, oButton4, oButton5, oFrame2, oFrame3

   WITH OBJECT oMain := WindowClass():New( .T. )
      :nCol     := 197
      :nRow     := 437
      :nWidth   := 550
      :nHEIGHT  := 350
      :Caption  := "Multi threads Sample"
      :Create( .T. )
   ENDWITH
E aqui, repassando as variáveis locais para a ação do button

Código: Selecionar todos

   WITH OBJECT oButton1 := ButtonClass():New()
      :nROW     := 10
      :nCOL     := 10
      :nWIDTH   := 160
      :nHEIGHT  := 28
      :bACTION  := { || main_button_1_action( @pClockThread, @oMain, @oButton1, @oLabel1, @oFrame2, @oFrame3 ) }
      :CAPTION := "Start Clock Thread"
      :Create( oMain )
   ENDWITH
Aqui não só usando as variáveis locais, mas repassando pra outra função

Código: Selecionar todos

FUNCTION main_button_1_action( /*@*/ pClockThread, oMain, oButton1, oLabel1, oFrame2, oFrame3 )

   //MsgExclamation("aqui" )
   Altd()
   IF ValType( oMain:GetProperty( "Cargo" ) ) == "L" .AND. oMain:GetProperty( "Cargo" )

      IF ! hb_threadQuitRequest( pClockThread )
         msgExclamation( "Can't stop thread!" )
      ELSE
         oButton1:SetProperty( "Cargo", .F. )
         oButton1:SetProperty( "Caption", "Start Clock Thread" )
            //oLabel1:SetProperty( "FontBold", .F. )
            //oLabel1:SetProperty( "FontSize", 10 )
         oLabel1:SetProperty( "Value", "00:00:00" )
         pClockThread := NIL
      ENDIF

      ShowThreadsIDs( oFrame2, oFrame3 )
      RETURN NIL

   ENDIF

   IF ! hb_mtvm()

      msgStop( "There is no support for multi-threading, clock will not be seen." )

   ELSE

      //oLabel1:SetProperty( "FontBold", .T. )
      //olabel1:SetProperty( "nFontSize", 12 )
      oButton1:SetProperty( "Caption", "Click to Stop Clock" )

      pClockThread := hb_threadStart( HB_THREAD_INHERIT_PUBLIC, { || Show_Time( oLabel1 ) } )
      oMain:SetProperty( "Cargo", .T. )

   ENDIF

   ShowThreadsIDs( oFrame2, oFrame3 )

   RETURN NIL
E a outra função usando o que recebeu

Código: Selecionar todos

PROCEDURE ShowThreadsIDs( oFrame2, oFrame3 )

   ALtd()
   oFrame2:Caption := "Clock (Thread pointer: " + hb_ntos( win_P2N( pClockThread ) ) +")"
   oFrame3:Caption := "Progressbar (Thread pointer: " + hb_ntos( win_P2N( pProgThread ) ) +")"

   RETURN
Estão usando só variáveis locais, nada das variáveis públicas da hmg.
O que se vê no fonte é o que está sendo usado, não tem manipulação de arquivo ch.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"

https://github.com/JoseQuintas/
ivanil
Usuário Nível 3
Usuário Nível 3
Mensagens: 166
Registrado em: 11 Set 2004 15:13
Localização: Florianópolis/SC

hmg extend com oop

Mensagem por ivanil »

Sim,
é justamente esse o motivo que implementei a classe, para poder enviá-lo como parâmetro;

Mas não vou te importunar mais,


Grande abraco.
Avatar do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20267
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP

hmg extend com oop

Mensagem por JoséQuintas »

Vixe....
Olhe só o troço...

Código: Selecionar todos

/*
   Multi-Thread sample by Roberto Lopez.
*/

STATIC pClockThread, pProgThread // hold pointers of threads

PROCEDURE Main

   LOCAL oMain, oFrame1, oLabel1, oProgbar1, oButton1, oButton2, oButton3
   LOCAL oButton31, oButton4, oButton5, oFrame2, oFrame3

   WITH OBJECT oMain := WindowClass():New( .T. )
      :nCol     := 197
      :nRow     := 437
      :nWidth   := 550
      :nHEIGHT  := 350
      :Caption  := "Multi threads Sample"
      :Create( .T. )
   ENDWITH

   WITH OBJECT oFrame1 := FrameClass():New()
      :nROW     := 10
      :nCOL     := 200
      :nWIDTH   := 315
      :nHEIGHT  := 278
      :CAPTION := "Threads"
      :Create( oMain )
   ENDWITH

   WITH OBJECT oLabel1 := LabelClass():New()
      :nROW     := 60
      :nCOL     := 290
      :nWIDTH   := 120
      :nHEIGHT  := 24
      :Caption := "Clock Here!"
      :Create( oMain )
   ENDWITH

   WITH OBJECT oProgbar1 := ProgbarClass():New()
      :nROW      := 150
      :nCOL      := 290
      :nWIDTH    := 150
      :nHEIGHT   := 30
      :nRANGEMIN := 1
      :nRANGEMAX := 10
      :Create( oMain )
   ENDWITH

   WITH OBJECT oButton1 := ButtonClass():New()
      :nROW     := 10
      :nCOL     := 10
      :nWIDTH   := 160
      :nHEIGHT  := 28
      :bACTION  := { || main_button_1_action( @pClockThread, @oMain, @oButton1, @oLabel1, @oFrame2, @oFrame3 ) }
      :CAPTION := "Start Clock Thread"
      :Create( oMain )
   ENDWITH

   WITH OBJECT oButton2 := ButtonClass():New()
      :nROW    := 50
      :nCOL    := 10
      :nWIDTH  := 160
      :nHEIGHT := 28
      :bACTION := { || main_button_2_action( @pProgThread, @oMain, @oProgbar1, @oButton2, @oFrame2, @oFrame3 ) }
      :CAPTION := "Start ProgressBar Thread"
      :Create( oMain )
   ENDWITH

   WITH OBJECT oButton3 := ButtonClass():New()
      :nROW    := 90
      :nCOL    := 10
      :nWIDTH  := 160
      :nHEIGHT := 28
      :bACTION := { || main_button_3_action( @pClockThread, @pProgThread ) }
      :CAPTION := "Stop All Threads"
      :Create( oMain )
   ENDWITH

   WITH OBJECT oButton31 := ButtonClass():New()
      :nROW     := 130
      :nCOL     := 10
      :nWIDTH   := 160
      :nHEIGHT  := 28
      :bACTION  := { || main_button_31_action( @pClockThread, @pProgThread ) }
      :CAPTION := "Start All Threads"
      :Create( oMain )
   ENDWITH

   WITH OBJECT oButton4 := ButtonClass():New()
      :nROW     := 220
      :nCOL     := 220
      :nWIDTH   := 260
      :nHEIGHT  := 28
      :bACTION  := { || main_button_4_action( pClockThread, pProgThread ) }
      :CAPTION := "Main Thread Button"
      :Create( oMain )
   ENDWITH

   WITH OBJECT oButton5 := ButtonClass():New()
      :nROW     := 250
      :nCOL     := 10
      :nWIDTH   := 160
      :nHEIGHT  := 28
      :bACTION  := {|| hb_threadTerminateAll(), DoMethod( "MainWin", "Release") }
      :CAPTION := "Exit (closing all threads)"
      :Create( oMain )
   ENDWITH

   WITH OBJECT oFrame2 := FrameClass():New()
      :nROW      := 30
      :nCOL      := 220
      :nWIDTH    := 272
      :nHEIGHT   := 75
      :cFONTNAME := 'Arial'
      :nFONTSIZE := 10
      :lFONTBOLD := .T.
      :CAPTION  := "Clock Thread - ID:"
      :lOPAQUE   := .T.
      :Create( oMain )
   ENDWITH

   WITH OBJECT oFrame3 := FrameClass():New()
      :nROW      := 120
      :nCOL      := 220
      :nWIDTH    := 272
      :nHEIGHT   := 75
      :cFONTNAME := 'Arial'
      :nFONTSIZE := 10
      :lFONTBOLD := .T.
      :CAPTION  := "Progressbar Thread - ID:"
      :lOPAQUE   :=.T.
      :Create( oMain )
   ENDWITH

   //END WINDOW
   _EndWindow()

   oButton1:Cargo := .F.
   oButton2:Cargo := .F.

   //ShowThreadsIDs( oFrame2, oFrame3 )

   oMain:Center()
   oMain:Activate()

   (oFrame1)
   (oLabel1)
   (oProgbar1)
   (oButton3)
   (oButton31)
   (oButton4)
   (oButton5)
   (oFrame2)
   (oFrame3)

   RETURN

FUNCTION Show_Time( oLabel1 )

   // please note that this function will NEVER return the control!
   // but do not 'locks' the user interface since it is running in a separate thread

   DO WHILE .T.
      oLabel1:Caption := Time()
      hb_idleSleep( 0.1 )
   ENDDO

   RETURN NIL

FUNCTION Show_Progress( oProgbar1 )

   LOCAL nValue

   DO WHILE .T.
      nValue := oProgbar1:Caption
      IF ValType( nValue ) != "N"
         IF ValType( nValue ) == "C"
            nValue := Val( nValue )
         ELSE
            nValue := 0
         ENDIF
      ENDIF
      nValue ++
      if nValue > 10
         nValue := 1
      endif
      oProgbar1:Caption := Ltrim( Str( nValue ) )
      hb_idleSleep( 0.2 )
   ENDDO

   RETURN NIL

PROCEDURE ShowThreadsIDs( oFrame2, oFrame3 )

   oFrame2:Caption( "Clock (Thread pointer: " + hb_ntos( win_P2N( pClockThread ) ) +")" )
   oFrame3:Caption( "Progressbar (Thread pointer: " + hb_ntos( win_P2N( pProgThread ) ) +")" )

   RETURN
Olhando o fonte:
Não tem nada que identifique HMGE, nem mesmo #include.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"

https://github.com/JoseQuintas/
Avatar do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20267
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP

hmg extend com oop

Mensagem por JoséQuintas »

A classe, postar em duas partes.
Primeiro cada objeto.
É praticamente traduzir o Create() para o formato da HMGE.

Talvez o inverso facilite, alterar o CH da HMGE acaba com a necessidade de criar tanta variável aqui.
Seria praticamente adicionar somente o classe:New() lá no ch
As variáveis aqui só são necessárias pro create(), removendo o create() também remove as variáveis.

Código: Selecionar todos

#include "hbclass.ch"
#include "hmg.ch"

STATIC nObject := 0

CREATE CLASS WindowClass INHERIT ObjectClass

   VAR cType        INIT "Mainwin"
   METHOD Create( oMain )

   ENDCLASS

METHOD Create( oMain ) CLASS WindowClass

   hb_Default( @oMain, .F. )
   IF oMain
      DEFINE WINDOW &(::cName) AT ::nCol, ::nRow ;
         WIDTH ::nWidth HEIGHT ::nHeight TITLE ::hAll[ "Caption" ] MAIN
   ENDIF
   ::lCreated := .T.

   RETURN Nil

CREATE CLASS FRAMEClass INHERIT ObjectClass

   VAR cType   INIT "Frame"
   VAR lOpaque INIT .F.
   METHOD Create( oMain )

   ENDCLASS

METHOD Create( oMain ) CLASS FrameClass

   ::oParent := oMain

   DEFINE FRAME &(::cName)
      ROW      ::nRow
      COL      ::nCol
      WIDTH    ::nWidth
      HEIGHT   ::nHeight
      CAPTION  ::hAll[ "Caption" ]
      FONTNAME ::cFontName
      FONTSIZE ::nFontSize
      FONTBOLD ::lFontBold
      CAPTION  ::hAll[ "Caption" ]
      PARENT   &( ::oParent:cName )
      OPAQUE   ::lOpaque
   END FRAME
   ::lCreated := .T.

   RETURN Nil

CREATE CLASS BUTTONClass INHERIT ObjectClass

   VAR  cType INIT "Button"
   METHOD Create( oMain )

   ENDCLASS

METHOD Create( oMain ) CLASS ButtonClass

   ::oParent := oMain

   DEFINE BUTTON &(::cName)
      ROW     ::nRow
      COL     ::nCol
      WIDTH   ::nWidth
      HEIGHT  ::nHeight
      ACTION  Eval( ::bAction )
      CAPTION ::hAll[ "Caption" ]
      PARENT &( ::oParent:cName )
   END BUTTON
   ::lCreated := .T.

   RETURN Nil

CREATE CLASS LABELClass INHERIT ObjectClass

   VAR cType INIT "Label"
   METHOD Create( oMain )

   ENDCLASS

METHOD Create( oMain ) CLASS LabelClass

   ::oParent := oMain

   DEFINE LABEL &(::cName)
      ROW    ::nRow
      COL    ::nCol
      WIDTH  ::nWidth
      HEIGHT ::nHeight
      VALUE  ::hAll[ "Caption" ]
      PARENT &( ::oParent:cName )
   END LABEL
   ::lCreated := .T.

   RETURN Nil

CREATE CLASS ProgbarClass INHERIT ObjectClass

   VAR cType INIT "Progbar"
   VAR nRangeMin INIT 0
   VAR nRangeMax INIT 0
   METHOD Create( oMain )

   ENDCLASS

METHOD Create( oMain ) CLASS ProgbarClass

   ::oParent := oMain

   DEFINE PROGRESSBAR &(::cName)
      ROW      ::nRow
      COL      ::nCol
      WIDTH    ::nWidth
      HEIGHT   ::nHeight
      RANGEMIN ::nRangeMin
      RANGEMAX ::nRangeMax
      PARENT &( ::oParent:cName )
   END PROGRESSBAR
   ::lCreated := .T.

   RETURN Nil
A classe herdada é apenas um tradutor, e o amontoado de variáveis na maioria pra porr.nenhuma, só pro create().
Ela é a segunda metade do fonte anterior, ela depende da variável STATIC nObject que está na primeira parte.
Mas se usar os nomes originais do fonte original, alterando o ch da HMG, essa parte de inventar nome também some.

Código: Selecionar todos

CREATE CLASS ObjectClass

   VAR cType        INIT "None"
   VAR oParent      INIT Nil
   VAR cName        INIT "X"
   VAR hAll         INIT hb_Hash()
   VAR nRow         INIT 0
   VAR nCol         INIT 0
   VAR nWidth       INIT 0
   VAR nHeight      INIT 0
   VAR cFontName    INIT "Arial"
   VAR nFontSize    INIT 10
   VAR lFontBold    INIT .F.
   VAR bAction      INIT { || Nil }
   VAR aControlList INIT {}
   VAR lCreated     INIT .F.
   METHOD New()
   METHOD Cargo( xValue )   SETGET
   METHOD Center()   INLINE ::DoMethod( "center" )
   METHOD Activate() INLINE ::DoMethod( "activate" )
   METHOD Caption( cText ) SETGET
   METHOD DoMethod( cName )
   METHOD GetProperty( cName )
   METHOD SetProperty( cName, xValue )

   ENDCLASS

METHOD New() CLASS ObjectClass

   nObject += 1
   IF ::cType == "Mainwin"
      ::cName := "Mainwin"
   else
      ::cName := ::cType + StrZero( nObject, 6 )
   ENDIF

   RETURN Self

METHOD Caption( cText ) CLASS ObjectClass

   IF cText != Nil
      ::hAll[ "Caption" ] := cText
      IF ::lCreated
         ::SetProperty( "Caption", cText )
      ENDIF
   ENDIF
   IF ::lCreated
      ::hAll[ "Caption" ] := ::GetProperty( "Caption" )
   ENDIF

   RETURN ::hAll[ "Caption" ]

METHOD DoMethod( cName ) CLASS ObjectClass

   LOCAL aList, oThis, oThisAnt

   aList := { ::cName }

   oThis := Self
   oThisAnt := oThis
   DO WHILE ( oThis := oThis:oParent ) != Nil
      hb_AIns( aList, 1, oThis:cName, .T. )
      oThisAnt := oThis
   ENDDO
   IF oThisAnt:lCreated
      DoMethod( hb_ArrayToParams( aList ), cName )
   ENDIF

   RETURN Nil

METHOD GetProperty( cName ) CLASS ObjectClass

   LOCAL aList, oThis, oThisAnt

   aList := { ::cName }

   oThis := Self
   oThisAnt := oThis
   DO WHILE ( oThis := oThis:oParent ) != Nil
      hb_AIns( aList, 1, oThis:cName, .T. )
      oThisAnt := oThis
   ENDDO
   IF oThisAnt:lCreated
      GetProperty( hb_ArrayToParams( aList ), cName )
   ENDIF

   RETURN Nil

METHOD SetProperty( cName, xValue ) CLASS ObjectClass

   LOCAL aList, oThis, oThisAnt // , cText

   aList := { ::cName }
   //MsgInfo( "atual " + ::cName )
   oThis := Self
   oThisAnt := oThis
   DO WHILE ( oThis := oThis:oParent ) != Nil
      hb_AIns( aList, 1, oThis:cName, .T. )
      oThisAnt := oThis
   ENDDO
   //cText := "SetProperty(" + ["] + aList[1] + ["]
   //DO CASE
   //CASE Len( aList ) == 2
   //   cText += "," + ["] + aList[2] + ["]
   //CASE Len( aList ) == 3
   //   cText += "," + ["] + aList[3] + ["]
   //CASE Len( aList ) == 4
   //   cText += "," + ["] + aList[4] + ["]
   //ENDCASE
   //cText += "," + ["] + cName + ["] + ","
   //DO CASE
   //CASE ValType( xValue ) == "C"; cText += ["] + xValue + ["]
   //CASE ValType( xValue ) == "N"; cText += Ltrim( Str( xValue ) )
   //CASE ValType( xValue ) == "D"; cText += "Stod(" + Dtos( xValue ) + ")"
   //CASE ValType( xValue ) == "L"; cText += iif( xValue, ".T.", ".F." )
   //OTHERWISE                    ; cText += Transform( xValue, "" )
   //ENDCASE
   //cText += ")"

   //MsgInfo( cText )

   IF oThisAnt:lCreated
      SetProperty( hb_ArrayToParams( aList ), cName, xValue )
   ENDIF

   RETURN Nil

METHOD Cargo( xValue ) CLASS ObjectClass

   IF xValue != Nil
      ::hAll[ "Cargo" ] := xValue
      IF ::lCreated
         ::SetProperty( "Cargo", xValue )
      ENDIF
   ELSE
      IF ::lCreated
         ::GetProperty( "Cargo", xValue )
      ENDIF
   ENDIF

   RETURN ::hAll[ "Cargo" ]
Basicamente a classe só precisa do nome original, e a indicaçào de quem é o parent.
Apesar de "talvez" poder fazer isso a partir da variável linguição da HMG, precisa fazer isso durante o fonte, pra poder usar tudo no próprio fonte, então tem que ser durante a criação e não depois.

Então... aqui estou ignorando qualquer nome usado pela HMG, apenas deixo em CNAME.
E por esse mesmo motivo, acaba impedindo o uso do que seria normal da HMG, porque "não tem nome", digamos assim. Obriga a alterar todo o fonte de uma vez, mas se não está pronto, não dá pra fazer isso.
Por exemlo, FontName e FontSize parecem não ser parte do objeto, deu erro pra ler/gravar essas propriedades.

Por enquanto é apenas um teste, pra avaliar se funciona.
Não dá pra imaginar tudo que pode acontecer sem fazer testes.
E tem que evitar mexer nos fontes da HMGE, porque tem versão nova quase toda semana, e não dá pra ficar refazendo tudo toda semana.
Já imagino que desse jeito o browse iria obrigar trocentas variáveis, o que não vai ser bom, vai complicar cada vez mais deixar compatível, sendo que a classe nem usa as variáveis pra nada.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"

https://github.com/JoseQuintas/
Avatar do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20267
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP

hmg extend com oop

Mensagem por JoséQuintas »

Uma alteração que mencionei antes, por enquanto tratando como "MainWin"

Código: Selecionar todos

METHOD IsCreated() CLASS ObjectClass

   DO WHILE ! ::lCreated .AND. ( oThis := oThis:oParent ) != Nil
      ::lCreated := oThis:lCreated
      IF oThis:Type == "Mainwin"
         EXIT
      ENDIF
   ENDDO

   RETURN ::lCreated
...
METHOD DoMethod( cName ) CLASS ObjectClass

   LOCAL aList, oThis, oThisAnt

   IF ! ::IsCreated() .AND. ::cName != "Mainwin"
      RETURN Nil
   ENDIF
   aList := { ::cName }

   oThis := Self
   oThisAnt := oThis
   DO WHILE ( oThis := oThis:oParent ) != Nil
      hb_AIns( aList, 1, oThis:cName, .T. )
      oThisAnt := oThis
   ENDDO
   DoMethod( hb_ArrayToParams( aList ), cName )
   IF cName == "Activate"
      ::lCreated := .T.
   ENDIF

   RETURN Nil
Porque se a janela ainda não foi ativada, nada existe na tela, nenhum controle.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"

https://github.com/JoseQuintas/
Avatar do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20267
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP

hmg extend com oop

Mensagem por JoséQuintas »

ivanil escreveu:Quanto ao assunto não depender do fonte HMG; é justamente o oposto do que penso, pois posso usar o designer para posicionar os objetos rapidamente sem interferir em absolutamente nada e quanto a mudanças no núcleo da minigui não faz muito sentido, qualquer coisa que venha a ser implementado seria uma propriedade, mas isso seria transparente... eu uso desta forma ha muitos anos e funciona bem.
Acho que não expliquei direito:
É deixar os fontes da HMG como são, sem mexer nos fontes da LIB.

Talvez mexer nos arquivos CH, pra manter a criação de controles original, e apenas acrescentar classe.

O quebra cabeças é: como usar por exemplo numa ACTION, se depender de primeiro processar o CH....

Do jeito que fiz o uso é direto: se quiser mexer num button, eu mexo nele, não importa aonde ele está, eu tenho o objeto button disponível, seja de onde for.
É até engraçado, mas na minigui tem tudo disponível também, já que tudo é variável pública, mas mesmo assim, pra mexer num controle precisa ter o caminho inteiro dele.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"

https://github.com/JoseQuintas/
Avatar do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20267
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP

hmg extend com oop

Mensagem por JoséQuintas »

Mas parece que tem um uso alternativo:

Encontrei isto no button:

Código: Selecionar todos

#ifdef _NAMES_LIST_
   _SetNameList( mVar , k )
#else
   Public &mVar. := k
#endif
e isto no minigui.ch

Código: Selecionar todos

/* ***********************************************************************
 * Enable this option if you want that the internal Public variables were
 * stored in the Global hash instead of the many Public variables.
 *
 * By default this is turned ON.
 */
#ifndef __XHARBOUR__
#define _NAMES_LIST_
#endif
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"

https://github.com/JoseQuintas/
Avatar do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20267
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP

hmg extend com oop

Mensagem por JoséQuintas »

e isto em outro ch

Código: Selecionar todos

#xtranslate _SetNameList( <x> , <v> )     => _SetGetNamesList( <x> , <v> )
e isto no statics

Código: Selecionar todos

#ifdef _NAMES_LIST_
*-----------------------------------------------------------------------------*
FUNCTION _SetGetNamesList( cName, nIndex, lDelete )
*-----------------------------------------------------------------------------*
   STATIC _HMG_NAMESLIST

   IF HB_ISNIL( _HMG_NAMESLIST )
      _HMG_NAMESLIST := oHmgData()
   ENDIF
e isto no ch

Código: Selecionar todos

#translate oHmgData( [ <lUpper> ] )       => THmgData():New( hb_defaultValue( <lUpper>, .T. ) )
e isto em prg

Código: Selecionar todos

CLASS THmgData
///////////////////////////////////////////////////////////////////////////////

   PROTECTED:
   VAR lUpp AS LOGICAL
   VAR aKey INIT hb_Hash()

   EXPORTED:
Pois é... como eu digo sempre, o fonte que se vê não é o fonte que é usado....
Fica difícil pra alguém de fora mexer em alguma coisa.

Achei até isto:

Código: Selecionar todos

/* ***********************************************************************
 * Enable support for the internal OOP classes
 *
 * By default this is turned ON.
 */
#define _OBJECT_
OOP ?
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"

https://github.com/JoseQuintas/
Avatar do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20267
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP

hmg extend com oop

Mensagem por JoséQuintas »

Parei de mexer com isso.
Talvez no futuro.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"

https://github.com/JoseQuintas/
Avatar do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20267
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP

hmg extend com oop

Mensagem por JoséQuintas »

ivanil escreveu:Assim como em hwgui, na minigui você também consegue trabalhar usando a boa prática de programação, ou seja, não misturar visão com lógica;(embora nos viciamos em fazer um pacotão só);
Agora que percebi como fez, e tem a ver diretamente com isso.

O desenho da tela só tem... o desenho da tela, mas sem os procedimentos adicionais.
Isso permite usar o código fonte normal da minigui pra desenhar telas (ou IDE).

Pra todo restante classes.
E todo restante é adicionado depois.

Provavelmente se olhar o fonte, vai dar até pra considerar que é outra LIB.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"

https://github.com/JoseQuintas/
Avatar do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20267
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP

hmg extend com oop

Mensagem por JoséQuintas »

oop.png
Por enquanto tá esquisito isso, não parece nada com OOP.
Acho que está sendo preparado pra isso aos poucos.
Nem sei como conseguem manter tudo que é opção que inventaram ao mesmo tempo.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"

https://github.com/JoseQuintas/
ivanil
Usuário Nível 3
Usuário Nível 3
Mensagens: 166
Registrado em: 11 Set 2004 15:13
Localização: Florianópolis/SC

hmg extend com oop

Mensagem por ivanil »

Ola Quintas;
JoséQuintas escreveu:O desenho da tela só tem... o desenho da tela, mas sem os procedimentos adicionais.
Isso permite usar o código fonte normal da minigui pra desenhar telas (ou IDE).
Nada impede você de colocar os eventos a serem disparados, inclusive às vezes eu faço assim.

Existe uma ordem nestas questões:

Load window xform as cadastro

se olhar o arquivo xform.fmg, tera a estrutura:

Define window ...
Define button ...
Action Teste(w)
ou
Action {||Teste(w)}
...
End button
..
end window

Então
Load window xform as cadastro
cadastro.activate()

Os eventos disparam apenas em activate, se tiver uma "ON INIT" no form, será disparada automaticamente, esse é o local ideal para alimentar os combos ou outros controles de seleção, pois deixa o código limpo e no devido lugar sem criar variáveis, apenas usando as propriedades de cada controle.

Partindo dessa ideia e sabendo como o bloco funciona então:

Local w
Load window xform as cadastro
w:=TWindow():New("cadastro")
cadastro.activate()

A variável local w, agora poderá ser repassada para todos os eventos e tudo está à disposição sem ter que mexer em nada da minigui, totalmente independente.
ivanil
Usuário Nível 3
Usuário Nível 3
Mensagens: 166
Registrado em: 11 Set 2004 15:13
Localização: Florianópolis/SC

hmg extend com oop

Mensagem por ivanil »

JoséQuintas escreveu:
oop.png
Por enquanto tá esquisito isso, não parece nada com OOP.
Acho que está sendo preparado pra isso aos poucos.
Nem sei como conseguem manter tudo que é opção que inventaram ao mesmo tempo.
Depois de uma olhada no arquivo h_objects.prg, faz bastante tempo que existe, mas percebi que o pessoal não gosta muito de lidar com objetos; embora também ache que as nomenclaturas adotadas nestas classes dificultam o aprendizado.
Avatar do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20267
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP

hmg extend com oop

Mensagem por JoséQuintas »

minigui.png
Por enquanto só está visível a variável linguição
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"

https://github.com/JoseQuintas/
Responder