'$INCLUDE:'FrameLibrary.BI'
CONST FileName$
= "tt.txt"
SearchTerms(0) = "TRICK": SearchTerms(1) = "TREAT"
SCREEN _NEWIMAGE(1280, 720, 32) '720p HD just cause I like it as a standard
LeftFrame
= NewTextArea
(0, 0, 400, _HEIGHT - 1, False
)ColorTextArea LeftFrame
, _RGB32(255, 255, 255), _RGB32(0, 0, 128)DrawTextArea LeftFrame
ColorTextArea RightFrame
, _RGB32(255, 255, 255), _RGB32(0, 0, 0)DrawTextArea RightFrame
LoadWordGrid
MakeDirectional
ShowGrid
FindWords
SetPrintStyleX RightFrame, CenterJustify
SetPrintUpdate RightFrame, NewLine
SetTextForeground RightFrame
, _RGB32(255, 255, 0) PrintOut RightFrame, "SEARCHING FOR " + SearchTerms(j)
SetTextForeground RightFrame
, _RGB32(255, 255, 255) PrintOut RightFrame, ""
PrintOut RightFrame, "Finding Left to Right Matches"
SetPrintStyleX RightFrame, NoJustify
SetPrintUpdate RightFrame, NoNewLine
foundone = 0
foundone
= INSTR(foundone
+ 1, YLines
(1, i
), SearchTerms
(j
)) PrintOut RightFrame
, "(Line" + STR$(i
) + ", Position" + STR$(foundone
) + "), " tc = tc + 1
SetPrintStyleX RightFrame, CenterJustify
SetPrintUpdate RightFrame, NewLine
PrintOut RightFrame, ""
PrintOut RightFrame, ""
PrintOut RightFrame, "Finding Right to Left Matches"
SetPrintUpdate RightFrame, NoNewLine
SetPrintStyleX RightFrame, NoJustify
foundone = 0
foundone
= INSTR(foundone
+ 1, YLines
(2, i
), SearchTerms
(j
)) PrintOut RightFrame
, "(Line" + STR$(i
) + ", Position" + STR$(X
- foundone
+ 1) + "), " tc = tc + 1
SetPrintStyleX RightFrame, CenterJustify
SetPrintUpdate RightFrame, NewLine
PrintOut RightFrame, ""
PrintOut RightFrame, ""
PrintOut RightFrame, "Finding Up to Down Matches"
SetPrintUpdate RightFrame, NoNewLine
SetPrintStyleX RightFrame, NoJustify
foundone = 0
foundone
= INSTR(foundone
+ 1, XLines
(1, i
), SearchTerms
(j
)) PrintOut RightFrame
, "(Line" + STR$(foundone
) + ", Position" + STR$(i
) + "), " tc = tc + 1
SetPrintStyleX RightFrame, CenterJustify
SetPrintUpdate RightFrame, NewLine
PrintOut RightFrame, ""
PrintOut RightFrame, ""
PrintOut RightFrame, "Finding Down to Up Matches"
SetPrintUpdate RightFrame, NoNewLine
SetPrintStyleX RightFrame, NoJustify
foundone = 0
foundone
= INSTR(foundone
+ 1, XLines
(2, i
), SearchTerms
(j
)) PrintOut RightFrame
, "(Line" + STR$(foundone
) + ", Position" + STR$(i
) + "), " tc = tc + 1
SetPrintUpdate RightFrame, NewLine
PrintOut RightFrame, ""
PrintOut RightFrame, ""
PrintOut RightFrame
, STR$(tc
) + " total matches found." PrintOut RightFrame, ""
PrintOut RightFrame, ""
tc = 0
'Print the words in the grid
SetTextColor LeftFrame
, _RGB32(255, 255, 0), 0 PrintOut LeftFrame, ""
PrintOut LeftFrame, " WORD GRID"
PrintOut LeftFrame, ""
SetTextColor LeftFrame
, _RGB32(255, 255, 255), 0 PrintOut LeftFrame, " " + YLines(1, i)
Y = Y + 1
WordGrid
(j
, i
) = MID$(junk$
, j
) 'Fill in the grid with the letters
YLines(1, i) = YLines(1, i) + WordGrid(j, i) 'Left to Right Lines
YLines(2, i) = YLines(2, i) + WordGrid(j, i) 'Right to Left Lines
XLines(1, i) = XLines(1, i) + WordGrid(j, i) 'Up to Down Lines
XLines(2, i) = XLines(1, i) + WordGrid(j, i) 'Right to Left Lines
'$INCLUDE:'FrameLibrary.BM'
Using Bplus's halloween challenge to do a wordsearch from a grid of letters in various directions, I came up with this little demo to highlight the flexibility and ease of use of my little TextFrame Library.
What *IS* the FrameLibrary, you ask??
It's a simple way to designate various areas of the screen to print and interact independently on. In this case, the left side holds the grid for us, while the right side prints out the results. If you look at the demo I posted over at the other forums, it has 4 designated frame areas which we can print to. (HERE:
http://qb64.freeforums.net/thread/46/text-frames )
Each of these frames are 100% independent of the others. You can set them to have various justification levels (left, right, center, no justification) for the text. You can set whether text prints to a new line when finished, or not. You can even set if the text frame is visible, or if you want to move it somewhere else onto the screen...
In the example here, we see how easy it is to designate our framed areas:
LeftFrame
= NewTextArea
(0, 0, 400, _HEIGHT - 1, False
)ColorTextArea LeftFrame
, _RGB32(255, 255, 255), _RGB32(0, 0, 128)DrawTextArea LeftFrame
ColorTextArea RightFrame
, _RGB32(255, 255, 255), _RGB32(0, 0, 0)DrawTextArea RightFrame
You can also see where we center our output text, while moving the pointer to a newline afterwards:
SetPrintStyleX RightFrame, CenterJustify
SetPrintUpdate RightFrame, NewLine)
And, where we change back to where we don't want to justify our text, or move to a new line after:
SetPrintStyleX RightFrame, NoJustify
SetPrintUpdate RightFrame, NoNewLine
Changing the color of the text is rather simple:
SetTextForeground RightFrame
, _RGB32(255, 255, 0)
And, doing the actual printing is as simple as:
PrintOut RightFrame, "SEARCHING FOR " + SearchTerms(j)
The library does automatic word-wrap. Automatic scrolling of a frame, if we print down to the bottom of the frame, just as QB64 does when we print at the bottom lines of the screen...
*******************************
*******************************
Honestly, it's not that complicated to use, once one tries it just a bit. Most of the commands mimic what we already have in QB64, with just the extra parameter in front for WHICH frame we're using.
PRINT whatever$ ---> PrintOut
frame, whatever$
COLOR fg, bg ---> SetTextColor
frame, fg, bg
LOCATE x, y ---> SetPrintPosition
frame, x, y
and so...
The only exception is when we go to adding NEW, non-native QB64 capabilities:
SetPrintStyleX frame, HOW --> frame is the same as above, HOW is: LeftJustify, RightJustify, CenterJustify, or NoJustify
In this case, LeftJustify prints our text at the left edge of the frame; RightJustify prints the text starting from the right edge of the frame, CenterJustify centers the text on the line, and NoJustify doesn't do any justification (much like a simple PRINT statement.)
**************************
**************************
Anywho... I thought I'd just share and show off the library a bit. I don't think many people have even taken a look at this one (much less used it), but I find it to be useful in a TON of things which I do. Being able to designate and print to multiple sections of the screen, without disturbing the rest of the screen, has always been something which I felt was too difficult to do -- thus, the birth of this. :D