Teste window panel como controle

Projeto MiniGui - Biblioteca visual para Harbour/xHarbour

Moderador: Moderadores

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

Teste window panel como controle

Mensagem por JoséQuintas »

É só teste simples.
Tem muito uso melhor que esse.

Código: Selecionar todos

#include "inkey.ch"
#include "set.ch"
#include "hmg.ch"
#include "hbclass.ch"

REQUEST HB_CODEPAGE_PTISO

STATIC nWindow := 0

PROCEDURE Main

   LOCAL oControl1, oControl2

   DEFINE WINDOW A ROW 0 COL 0 WIDTH 1024 HEIGHT 768 TITLE "test" WINDOWTYPE MAIN

      oControl1 := MyProgressbar():New()
      WITH OBJECT oControl1
         :Parent := "A"
         :Caption := "testing"
         :SetPos( 80, 10, 500, 50 )
         :BackColor := YELLOW
         :Create()
      ENDWITH
      oControl2 := MyProgressbar():New()
      WITH OBJECT oControl2
         :Parent := "A"
         :Caption := "testing"
         :SetPos( 160, 10, 500, 50 )
         :BackColor := BLUE
         :Create()
      ENDWITH

      DEFINE BUTTON BUTTON_1
         ROW		40
			COL		10
			CAPTION		'Click Me!'
			ACTION		Eval( { || oControl1:SetValue( oControl1:nValue + 10 ), ;
                     oControl2:SetValue( oControl2:nValue + 10 ) } )
			DEFAULT		.T.
		END BUTTON

   END WINDOW

   ACTIVATE WINDOW A

   RETURN

CREATE CLASS MyProgressbar
   VAR name
   VAR nRow
   VAR nCol
   VAR nWidth
   VAR nHeight
   VAR Caption
   VAR BackColor
   VAR nMax   INIT 500
   VAR nValue INIT 0
   VAR Parent
   METHOD Create()
   METHOD SetPos( r, c, w, h ) INLINE ::nRow := r, ::nCol := c, ::nWidth := w, ::nHeight := h
   METHOD SetValue( n ) INLINE ::nValue := iif( ::nValue > 500, 500, n ), ::Paint()
   METHOD Paint()
   ENDCLASS

METHOD Create() CLASS MyProgressbar

   nWindow += 1
   ::Name := "W" + StrZero( nWindow, 3 )

   DEFINE WINDOW ( ::Name ) ;
      ROW ::nRow ;
      COL ::nCol ;
      WIDTH ::nWidth ;
      HEIGHT ::nHeight ;
      WINDOWTYPE PANEL

      DEFINE LABEL LABEL_1
         ROW 10
         COL 10
         VALUE ::Caption
         BORDER .T.
         WIDTH 1
         HEIGHT 20
         BACKCOLOR ::BackColor
      END LABEL
   END WINDOW

   RETURN Nil

METHOD Paint() CLASS MyProgressbar

   SetProperty( ::Name, "label_1", "width", ::nValue )

   RETURN Nil
test.png
test.png (11.32 KiB) Exibido 2591 vezes
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

Teste window panel como controle

Mensagem por JoséQuintas »

Compliquei pra facilitar....

Código: Selecionar todos

#include "inkey.ch"
#include "set.ch"
#include "hmg.ch"
#include "hbclass.ch"

REQUEST HB_CODEPAGE_PTISO

STATIC nWindow := 0

PROCEDURE Main

   LOCAL oControl, aControlList := Array(6), nColor, nRow


   DEFINE WINDOW A ROW 0 COL 0 WIDTH 1024 HEIGHT 768 TITLE "test" WINDOWTYPE MAIN

      FOR EACH oControl, nRow, nColor IN aControlList, ;
         { 80, 160, 240, 320, 400, 480 }, { YELLOW, BLUE, GREEN, RED, ORANGE, BLACK }
         oControl := MyProgressbar():New( "A", nRow, 10, 500, 50, "test", nColor )
      NEXT

      DEFINE BUTTON BUTTON_1
         ROW		40
			COL		10
			CAPTION		'Click Me!'
			ACTION		AEval( aControlList, { | e | e:SetValue( e:nValue + 10 ) } )
			DEFAULT		.T.
		END BUTTON

   END WINDOW

   ACTIVATE WINDOW A

   RETURN
e a classe:

Código: Selecionar todos


CREATE CLASS MyProgressbar
   VAR name
   VAR nMax   INIT 500
   VAR nValue INIT 0
   VAR Parent
   METHOD New( Parent, row, col, width, height, title, color )
   METHOD SetValue( n ) INLINE ;
      ::nValue := iif( ::nValue > 500, 500, n ), ;
      SetProperty( ::Name, "label_1", "width", ::nValue )
   ENDCLASS

METHOD New( Parent, row, col, width, height, title, color ) CLASS MyProgressbar

   ::Parent := Parent
   nWindow += 1
   ::Name := "W" + StrZero( nWindow, 3 )

   DEFINE WINDOW ( ::Name ) ;
      ROW row ;
      COL col ;
      WIDTH width ;
      HEIGHT Height ;
      WINDOWTYPE PANEL

      DEFINE LABEL LABEL_1
         ROW 10
         COL 10
         VALUE title
         BORDER .T.
         WIDTH 1
         HEIGHT 20
         BACKCOLOR color
      END LABEL
   END WINDOW

   RETURN Self
E o resultado, 6 controles progressbar criados usando window panel
test.png
A cada clique no button, os 6 vão aumentando o progresso.
Detalhe a mais: OOP neles, seguem minigui normal mas são 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

Teste window panel como controle

Mensagem por JoséQuintas »

Aproveitando...

O que eu reclamava antigamente da minigui era de não poder fazer isso.

Daquela época pra cá, considero duas coisas fantásticas:
- poder escolher o nome DECLARE WINDOW (nome)
- sintaxe alternativa, onde dá pra ver erro na linha exata aonde está errado.

Não sei quando isso foi introduzido, mas isso fazia muita falta, tudo fica mais flexível assim.
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

Teste window panel como controle

Mensagem por JoséQuintas »

test.png
É só teste aleatório, não finalizado.
Mesmo fonte principal.

Código: Selecionar todos

PROCEDURE Main

   LOCAL oControl, aControlList := Array(6), nColor, nRow

   DEFINE WINDOW A ROW 0 COL 0 WIDTH 1024 HEIGHT 768 TITLE "test" WINDOWTYPE MAIN

      FOR EACH oControl, nRow, nColor IN aControlList, ;
         { 80, 160, 240, 320, 400, 480 }, { YELLOW, BLUE, GREEN, RED, ORANGE, BLACK }
         oControl := MyProgressbar():New( "A", nRow, 10, 500, 50, "test", nColor )
      NEXT

      DEFINE BUTTON BUTTON_1
         ROW      40
         COL      10
         CAPTION      'Click Me!'
         ACTION      AEval( aControlList, { | e | e:SetValue( e:nValue + 10 ) } )
         DEFAULT      .T.
      END BUTTON

   END WINDOW

   ACTIVATE WINDOW A

   RETURN
Mas agora MyProgressbar() já faz o cálculo de tempo gasto e tempo restante.
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