bb.donnay-software.com

Donnay Software Web Forums
It is currently Mon May 25, 2020 11:10 am

All times are UTC - 7 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Tue Nov 03, 2015 5:15 pm 
Offline
User avatar

Joined: Tue Jul 28, 2015 5:15 am
Posts: 94
This is the big question. How do I move from TEXT mode to GUI mode. It looks so difficult.
Well, eXpress++ is there for that and I will explain in words for beginners how it works.

In TEXT mode, it a very small world, you could do an application that execute a set of command and then quits. You could be a bit more fancy doing a loop like

DO WHILE

SHOW MENU1
SHOW MENU2

DO CASE
CASE MENU1
CODE
CASE MENU2
CODE

ENDDO

You have just created a loop. You can do more with a menu function that does it all but you are only managing keyboard inputs.
Onces you would like to manage mouse, keyboard, and other input devices, you need to have a event loop. And base on the event result, action is required. You could start creating all your events, but on a large application, you have a lot of your ahead.

If you look at the Graphic User Interface, GUI, it´s all about mouse and windows. And they are all kind of linked together. This is where Object Oriented Programming is needed. But this is scary too.

eXpress++ will do this part, create the dialogs, the windows, the objects in a simple commands set.
Commands have a big advantage. You can have many options and you dont have to pass them as parameters.

So just like you use to have

@ 10, 10 SAY "MY NAME IS" GET cName
READ

Now you would do

@ 10, 10 DCSAY "MY NAME IS" GET cName
DCREAD GUI

And this creates the windows, manages events etc. That simple.

There is more to understand, I will continue in another post.


Top
 Profile  
 
PostPosted: Wed Nov 04, 2015 5:05 am 
Offline
User avatar

Joined: Tue Jul 28, 2015 5:15 am
Posts: 94
Xbase++ supports a non-gui console mode for migration of Clipper or FoxPro 2.6 applications. By default, console mode is always enabled via the AppSys() function which is always called before Main(). APPSYS.PRG contains the default source code.

This procedure is added automatically to your application.
It creates a CRT that will allow you to use ?, MENU TO, @..SAY, @..PROMPT, SetColor()

If you want to be in GUI, you need to turn it OFF

Just add before your main function

PROCEDURE APPSYS
RETURN


Top
 Profile  
 
PostPosted: Wed Nov 04, 2015 5:14 am 
Offline
User avatar

Joined: Tue Jul 28, 2015 5:15 am
Posts: 94
Now that you have your application in hybride mode, you will realize that you can´t change the size of the window anymore.
And probably the font is too small. You get a very small window.

This is what you need to be able to change the font size.

Change the name of your app.
In this example I have chosen to change the fonts with CTRL-F1. You can change this base on your application.

When you get to your application, when you have a get, you can hit CTRL-F1 and you can change the font for the CRT.
The results will be saved to crtfont.ini for next time.

Code:
******************************************************************************
PROCEDURE AppSys()

  LOCAL oCrt, nAppType := AppType(), nCol, nRow, oParent, aCrtDef, ;
        aCrtData

  aCrtDef := { 'FontHeight', 'FontWidth', 'FontName' }
  aCrtData := { 12, 8, Pad('Alaska Crt',50) }

  DC_IniLoad( 'CRTFONT.INI',  { { 'CRTWINDOW',  aCrtData,  aCrtDef } } )

      // First active SetAppWindow() == Desktop
  oParent := AppDesktop ( SetAppWindow() )
  nCol := (oParent:currentSize()[1]-620)/2
  nRow := (oParent:currentSize()[2]-400)/2

  // Create XbpCRT object
  oCrt := XbpCrt():New ( oParent, NIL, { nCol, nRow }, 25, 80, nil, .f. )
  oCrt:FontWidth  := aCrtData[2]
  oCrt:FontHeight := aCrtData[1]
  oCrt:FontName   := Alltrim(aCrtData[3])
  oCrt:Title      := "ChangeYourApplicationNameHere"
  oCrt:border     := XBPDLG_RECESSEDBORDERTHICK_FIXED
  oCrt:icon       := DC_IconDefault()
  SetKey( K_CTRL_F1, {||SelectFont(oCrt)} )

  oCrt:Create()

  // Init Presentation Space
  oCrt:PresSpace()

  DC_CenterObject(oCrt)
  oCrt:show()

  // XbpCrt gets active window and output device
  SetAppWindow( oCrt )
  SetAppFocus( oCrt )

RETURN
******************************************************************************
FUNCTION SelectFont( oCrt )

LOCAL aFonts, nPointer := 1, oBrowse, lOk, GetList := {}, aCrtData, aCrtDef, ;
      cFontName, oFont, oFontDlg, oPS, oDialog

aFonts := { ;
   { 'Lucida Console', 10, 16 }, ;
   { 'Lucida Console', 11, 18 }, ;
   { 'Lucida Console', 12, 20 }, ;
   { 'Lucida Console', 13, 22 }, ;
   { 'Lucida Console', 14, 23 }, ;
   { 'Lucida Console', 15, 25 }, ;
   { 'Lucida Console', 16, 26 }, ;
   { 'Lucida Console', 17, 28 }, ;
   { 'Lucida Console', 3, 5 }, ;
   { 'Lucida Console', 4, 6 }, ;
   { 'Lucida Console', 4, 7 }, ;
   { 'Lucida Console', 5, 8 }, ;
   { 'Lucida Console', 6, 10 }, ;
   { 'Lucida Console', 7, 12 }, ;
   { 'Lucida Console', 8, 14 }, ;
   { 'Lucida Console', 9, 15 }, ;
   { 'Lucida Console', 10, 16 }, ;
   { 'Lucida Console', 11, 18 }, ;
   { 'Lucida Console', 12, 20 }, ;
   { 'Lucida Console', 13, 22 }, ;
   { 'Lucida Console', 14, 23 }, ;
   { 'Lucida Console', 15, 25 }, ;
   { 'Lucida Console', 16, 26 }, ;
   { 'Lucida Console', 17, 28 }, ;
   { 'Lucida Console', 18, 30 }, ;
   { 'Lucida Console', 19, 31 }, ;
   { 'Lucida Console', 20, 33 }, ;
   { 'Lucida Console', 21, 35 }, ;
   { 'Lucida Console', 22, 36 }, ;
   { 'Lucida Console', 23, 38 }, ;
   { 'Lucida Console', 24, 40 }, ;
   { 'Lucida Console', 25, 42 }, ;
   { 'Lucida Console', 26, 43 }, ;
   { 'Lucida Console', 27, 45 }, ;
   { 'Lucida Console', 28, 46 }, ;
   { 'Lucida Console', 29, 48 }, ;
   { 'Lucida Console', 30, 50 }  }

@ 0,0 DCBROWSE oBrowse DATA aFonts SIZE 30,11 ;
      DATALINK {||DC_ReadGuiEvent(DCGUI_EXIT_OK,GetList)} ;
      POINTER nPointer FIT PRESENTATION DC_BrowPres() ;
      NOSOFTTRACK

DCBROWSECOL ELEMENT 1 PARENT oBrowse HEADER 'Font Name' WIDTH 10
DCBROWSECOL ELEMENT 2 PARENT oBrowse HEADER 'Width' WIDTH 4
DCBROWSECOL ELEMENT 3 PARENT oBrowse HEADER 'Height' WIDTH 4

DCREAD GUI FIT ADDBUTTONS TO lOk MODAL TITLE 'Select a CRT Font'

IF lOk

  IF aFonts[nPointer,1] = 'Pick'

    oDialog := XbpDialog():New()
    oDialog:create()
    oPS := oDialog:drawingArea:LockPs()
    oFontDlg := XbpFontDialog():New(AppDeskTop(),,,oPS)
    oFontDlg:fixedOnly := .t.
    oFontDlg:create()
    oFont := oFontDlg:display( XBP_DISP_APPMODAL )
    cFontName := ''
    IF Valtype(oFont) = 'O'
      cFontName := Alltrim(Str(oFont:nominalPointSize))+'.'+ ;
                   oFont:compoundName
    ENDIF
    oPS:destroy()
    oDialog:destroy()
    oFontDlg:destroy()
    IF Valtype(oFont) = 'O'
      aFonts[nPointer,1] := oFont:familyName
      aFonts[nPointer,2] := oFont:width
      aFonts[nPointer,3] := oFont:height
    ELSE
      RETURN nil
    ENDIF
  ENDIF

  oCrt:fontName := aFonts[nPointer,1]
  oCrt:fontWidth := aFonts[nPointer,2]
  oCrt:fontHeight := aFonts[nPointer,3]
  oCrt:configure()
  DC_CenterObject(oCrt)

  aCrtDef := { 'FontHeight', 'FontWidth', 'FontName' }
  aCrtData := { aFonts[nPointer,3], aFonts[nPointer,2], aFonts[nPointer,1] }

  DC_IniSave( 'CRTFONT.INI',  { { 'CRTWINDOW',  aCrtData,  aCrtDef } } )

ENDIF

RETURN nil
******************************************************************************


Top
 Profile  
 
PostPosted: Wed Nov 04, 2015 5:38 am 
Offline
User avatar

Joined: Tue Jul 28, 2015 5:15 am
Posts: 94
Now, add some GUI content to your application.

Change your messages to a GUI window.
If you have a login, get the login and password in a GUI.

How to do that? there almost a sample for everything.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group