Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Confusion about graphics text

WSinc
New Contributor I
983 Views
Am I to understand that there is only allowable size for the
graphics text when you CALL OUTTEXT()?

The reason I ask is that there is a text coordinate system implied,
which assumes that the horizontal & vertical position is tied down
to a particular graphics size.

I am referring to the Quickwin routines. Maybe another graphics
package does not have that restriction?
0 Kudos
7 Replies
Paul_Curtis
Valued Contributor I
983 Views
Billsincl,
If you want your codes to access the full versatility of Windows programming, you will need to take off the training wheels (ie, "Quickwin") and learn how the Windows API actually works. The best way to do this is to get one of Petzold's older (pre-MFC) books; "Programming Windows95" or "Programming Windows98" would be excellent starting points, and it is very straightforward to translate his C programming samples into Fortran. That is how almost all Windows API programmers (including this one) learned how to do it, takes a few months' effort, but the payback is complete Windows programming, and you won't need one stick of C code either.

Here is some sample code anent your question on text output in a graphical context, to give you an idea of the ease and versatility accessible from the API:

[bash]!  create some fonts in different sizes
hfont_14 = CreateSimpleFont ('Arial'C, 14, .FALSE., .FALSE.)
hfont_16 = CreateSimpleFont ('Arial'C, 16, .FALSE., .FALSE.)
hfont_15 = CreateSimpleFont ('Arial'C, 15, .FALSE., .FALSE.)

!  get a handle to a device context associated with window hwin
hdc = GetDC (hwin)

!  load a font for drawing text
iret = SelectObject (hdc, hfont_14)

!  client rectangle for the parent window, for text positioning
iret = GetClientRect (hwin, crect)

!  draw some text
iret = MSFWIN$SetTextColor (hdc, 0)  ! black
iret = SetBkMode           (hdc, TRANSPARENT)
iret = SetTextAlign        (hdc, IOR(TA_LEFT,TA_TOP))
iret = TextOut             (hdc, crect%left, crect%top, 'your message', 12)

!  clean up
iret = ReleaseDC (hwin, hdc)





! Creates a font with simple characteristics. The face name and size
! are provided, along with bold and italic flags. Returns a handle
! to the new font, or 0 on failiure.
!
INTEGER(HANDLE) FUNCTION CreateSimpleFont (faceName, size, bold, italic)
    IMPLICIT NONE
    CHARACTER(LEN=*), INTENT(IN)   :: faceName
    INTEGER, INTENT(IN)            :: size
    LOGICAL, INTENT(IN)            :: bold
    LOGICAL, INTENT(IN)            :: italic

    TYPE(T_LOGFONT)                :: logfont
    INTEGER(HANDLE)                :: hfont

    logfont%lfHeight		= size
    logfont%lfWidth			= 0
    logfont%lfEscapement	= 0
    logfont%lfOrientation	= 0
    IF (bold) THEN
        logfont%lfWeight = FW_BOLD
    ELSE
        logfont%lfWeight = FW_NORMAL
    END IF
    logfont%lfItalic			= italic
    logfont%lfUnderline			= .FALSE.
    logfont%lfStrikeout			= .FALSE.
    logfont%lfCharSet			= ANSI_CHARSET
    logfont%lfOutPrecision		= OUT_DEFAULT_PRECIS
    logfont%lfClipPrecision		= CLIP_DEFAULT_PRECIS
    logfont%lfQuality			= DEFAULT_QUALITY
    logfont%lfPitchAndFamily	= IOR(DEFAULT_PITCH, FF_DONTCARE)
	logfont%lfFaceName			= faceName

    hfont = CreateFontIndirect (logfont)

    CreateSimpleFont = hfont

END FUNCTION CreateSimpleFont
[/bash]
0 Kudos
Robert_van_Amerongen
New Contributor III
983 Views
I fully agree with what Paul wrote. Learning WINAPI take some time, but once you have understood the basics the rest goes rather quick. Besides Petzold, there are some other sources you can use, just look for a tutorial on the web.

Robert van Amerongen
0 Kudos
dboggs
New Contributor I
983 Views
Is there some reason you cannot use OUTGTEXT? OUTTEXT is intended for "plain text" only, while OUTGTEXT is intended for "graphic" text. As such, you first call INITIALIZEFONTS(), then specify any font you want (including height) by calling SETFONT. If you want it in a special color then call SETCOLOR. You should be able to find details easily in the documentation. Let me know if you need help.
0 Kudos
WSinc
New Contributor I
983 Views
Well, considering that I need to solve the problem in the fairly near future,
and not in a few months -

Would I get more flexibilty by using Standard Windows graphics, rather than Quickwin?
0 Kudos
WSinc
New Contributor I
983 Views
My application requires me to output arrays of numbers using mixed colors,
I.e. in the same output line, one can have several different colors in it.

So I can't just set a color before issuing a Print statement for example.
I would have to change font colors "on the fly." But all the font charcters would have the same size.

This is a good answer, since I don't have time right now to learn all the ins and outs of API.
0 Kudos
Paul_Curtis
Valued Contributor I
983 Views
Can't comment on your schedule/time management issues, or your mindspace availability for new ideas, but "changing text colors on the fly" is easily possible with the correct toolset.

The following, for example, is a code fragment extracted from a much larger routine, which renders non-printable characters as 2-digit hex values, and for which the readability is greatly improved by rendering each set of hex digits in alternating colors so the bytewise content becomes clear. This code is in the middle of a j-loop over the content of character buffer tracestring(), and the x position xpos is (elsewhere in the loop) advanced by the display width of the characters following each TextOut. This code can crank out multicolored text into a scrolling text window at hundreds of lines per second:

[bash]hextoggle = 3 - hextoggle	! swap hex display colors
IF (mode /= hex) THEN
	iret = MSFWIN$SetBkColor (hdc, bk_hex)
	mode = hex
END IF
iret = MSFWIN$SetTextColor (hdc, hexcolor(hextoggle))
WRITE (hexout, '(Z2.2)') ICHAR(tracestring(j:j))
iret = TextOut (hdc, xpos, ypos, hexout, 2)
hexcount = hexcount + 1
[/bash]
0 Kudos
billsinclaol_com
Beginner
983 Views
THAT WAS VERY HELPFUL - - -

Thanks ! !
0 Kudos
Reply