'this is future "TextBox.BI"
TYPE Colored
' This Array contains colors positions on text and color values. This array is created in SUB CString.
B
AS INTEGER ' Text begin in textbox (for shift), X axis BH
AS INTEGER ' Text begin in textbox (for shift), Y axis NEW
D
AS SINGLE ' for time delay between click to arrows filter
AS _BYTE 'new info flag for CString, which is needed just in the start, but not more.
REDIM SHARED GlobalText
(0) AS STRING 'spolecne obrovske textove pole obsahujici texty pro vsechna okna vcetne udaju o barvach
SCREEN _NEWIMAGE(1980, 1050, 256) 'screen must be initialized before PutArrow& is run. Arrow0 = PutArrow
R90 Arrow0, Arrow1, Arrow2, Arrow3 'create four arrows in four directions from first source image
'end of future "TextBox.BI"
Text1(1) = "/14This is content /1for /2array /3Text1. Original and source text array content is in"
Text1(2) = "/44array Text1. Because Petr can just 2 ways (first: MEM Pointer to array insert"
Text1(3) = "/45to type), or second, easyest - all texts insert to one STRING SHARED array, and"
Text1(4) = "/46writing informations about start and end index to TYPE, is now this text also"
Text1(5) = "/47inserted to array named as GlobalText. Because this text contains 7 rows and "
Text1(6) = "/48Text1 array is inserted as first, is this saved in indexes 0 to 6 in array"
Text1(7) = "/49GlobalText. Info about this records are here saved to TBA2().I_s and TBA2().I_e"
Text2(1) = " /14 Example for use:"
Text2(2) = "/45With /40'/90/'/40 /45and then number you set colors. If you use _SCREEN _NEWIMAGE in 256 colors,"
Text2(3) = "then use number from 0 to 256. But if you use 32 bit screen, then dont use &H values but"
Text2(4) = "/50 number. This number can be returned using this easy source code:"
Text2(5) = "/55 COLOR~& = &HFFFFFFFF /60 or /55 COLOR~& = _RGBA32(255, 255, 255)"
Text2(6) = "PRINT COLOR~&. /60 This is number, which you need for use to 32 bit screens with this"
Text2(7) = "easy program. (i write soon automatic translator for it, but with my time....)/9"
Text2(8) = "Program construction: - All strings are saved to array /14 GlobalText."
Text2(9) = " /9 - Function /14R90/9 create 4 images which contains rows, rotated from 1"
Text2(10) = " source image, which is created with Function /14PutArrow./9"
Text2(11) = " - /14CString /9SUB create help array for colors used in text to array /14K/9."
Text2(12) = " - /14MaximalRowLenght/9 Function return lenght of longest row in text array."
Text2(13) = " - Function /14INITBOX2/9 write all needed records to program arrays and return record number."
Text2(14) = " - /14XY_BOX /9SUB - own program. Study it /33yourself /40:-)"
boxes(B1) = INITBOX2(-158 + 198 * B1, 50, Text1(), 17, 10)
boxes(B1) = INITBOX2(-158 + 198 * (-10 + B1), 250, Text2(), 17, 10)
boxes(B1) = INITBOX2(-158 + 198 * (-20 + B1), 450, Text1(), 17, 15)
co = 40
boxes(B1) = INITBOX2(co, 700, Text2(), 35, 20)
co = co + 400
XY_BOX boxes(B1)
XY_BOX boxes(B1)
XY_BOX boxes(B1)
XY_BOX boxes(B1)
'this is future "TextBox.BM"
TBA2(UTB + 1).X = X
TBA2(UTB + 1).Y = Y
TBA2(UTB + 1).L = BoxLenght
TBA2(UTB + 1).H = BoxHeight
TBA2(UTB + 1).T = ""
TBA2(UTB + 1).I_s = U1
TBA2(UTB + 1).I_e = U1 + U2
FOR insert
= U1
TO U1
+ U2
GlobalText(insert) = Text(t)
t = t + 1
TBA2(UTB + 1).BH = U1 + 1 'after first start: first row (BH is shift in Y, B is shift in X axis)
TBA2(UTB + 1).B = 1 'and first column
INITBOX2 = UTB + 1
'
RowLen = MaximalRowLenght(nr)
B = TBA2(nr).B
BH = TBA2(nr).BH
X = TBA2(nr).X
Y = TBA2(nr).Y
BoxLenght = TBA2(nr).L - 2
Init = TBA2(nr).init
onpos = 1
'256/32 color support:
Black~& = 0
White~& = 15
Grey~& = 24
Grey2~& = 19
Black~& = &HFF000000
White~& = &HFFFFFFFF
Grey~& = &H226666666
Grey2~& = &HFF221122
RowLen = MaximalRowLenght(nr)
B = TBA2(nr).B
BH = TBA2(nr).BH
X = TBA2(nr).X
Y = TBA2(nr).Y
BoxLenght = TBA2(nr).L - 2
' WHILE _MOUSEINPUT:
' mwh = mwh + _MOUSEWHEEL
' IF mwh THEN EXIT WHILE
' WEND
' IF _MOUSEX >= X - 30 AND _MOUSEX <= X + 30 + BoxLenght * _FONTWIDTH THEN
' IF _MOUSEY >= Y - 3 AND _MOUSEY <= Y + 3 + 2 * TextHeight THEN
' B = B + mwh * 4
' END IF
' END IF
'
' MB1 = _MOUSEBUTTON(1)
' MX = _MOUSEX
' MY = _MOUSEY
LINE (X
- 30, Y
)-(X
+ 30 + BoxLenght
* _FONTWIDTH, Y
+ BoxHeight
), Grey~&
, BF
'vnitrek okna window inside LINE (X
- 30, Y
- 3)-(X
+ 30 + BoxLenght
* _FONTWIDTH, Y
+ BoxHeight
), White~&
, B
LINE (X
- 28, Y
- 1)-(X
+ 28 + BoxLenght
* _FONTWIDTH, Y
+ BoxHeight
- TextHeight
), White~&
, B
'borders for lines up / down
' slider X calculations. For calculating slider lenght you need the number of characters of the longest sentence used in the box. MaximalRowLenght function return it:
'////////////////////////////////////////////////////////
TL = B / RowLen * 100 'pocatecni poloha pruhu v procentech begining position for bottom box (percentually)
L
= TBA2
(nr
).L
* _FONTWIDTH 'celkova delka pruhu v pixelech total slide lenght in pixels Actual
= _CEIL(X
+ (TL
/ 100 * L
)) ' graphic position for bottom box BL = boxl / (TextLenght / 100) 'delka posuvneho boxiku v procentech box on bottom lenght (how it is done: Slider lenght is percentually size as window bottom (for X - Shift).
' if 30 percent of the sentence length is visible in the window, then the slider is 30 percent of the length of the X-side this window
IF BL
> 100 THEN BL
= 100 ' if text lenght < window X side, draw slider as 100 percent of X window side
BBL = boxl / 100 * BL
'posuvnik X Slider X
LINE (Actual
, Y
+ BoxHeight
- TextHeight
+ 5)-(Actual
+ BBL
, Y
+ BoxHeight
- TextHeight
+ 12), White~&
, BF
LINE (Actual
, Y
+ BoxHeight
- TextHeight
+ 5)-(Actual
+ BBL
, Y
+ BoxHeight
- TextHeight
+ 12), Grey2~&
, B
'////////////////////////////////////////////////////////////
'slider Y (the same os for X slider)
DelkaSteny
= BoxHeight
- TextHeight
- (2 * _FONTHEIGHT) - 2 Zaznamu100 = ZaznamuNaStenu / (TBA2(nr).I_e - TBA2(nr).I_s) * 100
BBH = (Zaznamu100 / 100) * DelkaSteny
IF BBH
> DelkaSteny
THEN BBH
= DelkaSteny
Pozice = 1 + (BH - TBA2(nr).I_e) / TBA2(nr).I_e
actualH
= Y
+ _FONTHEIGHT + ((DelkaSteny
- BBH
) * Pozice
)
'posuvnik Y Slider Y
LINE (TBA2
(nr
).X
+ TBA2
(nr
).L
* _FONTWIDTH, actualH
)-(TBA2
(nr
).X
+ TBA2
(nr
).L
* _FONTWIDTH + 7, actualH
+ BBH
), White~&
, BF
LINE (TBA2
(nr
).X
+ TBA2
(nr
).L
* _FONTWIDTH, actualH
)-(TBA2
(nr
).X
+ TBA2
(nr
).L
* _FONTWIDTH + 7, actualH
+ BBH
), Grey2~&
, B
' solution for moving text by click + move to down box
IF MY
>= Y
+ BoxHeight
- TextHeight
AND MY
<= Y
+ BoxHeight
THEN omx = MX
' solution for moving text up and down by clicking and move to box on right
IF MY
>= Y
+ 16 AND MY
<= Y
+ BoxHeight
- 40 THEN omy = MY
ABY = Y + 2 + BoxHeight - TextHeight ' ArrowBottomY coordinate
LUPAC
= X
+ 15 + BoxLenght
* _FONTWIDTH ' Left UP/Down Arrow coordinate
_PUTIMAGE (LUPAC
, ABY
), Arrow0&
' Arrow to right _PUTIMAGE (LUPAC
- 1, Y
+ TextHeight
* (TBA2
(nr
).H
- 2)), Arrow2&
' down
'driving up arrow
LINE (LUPAC
, Y
+ 2)-(LUPAC
+ 12, Y
+ 14), &H44FFFFFF, BF
LINE (LUPAC
, Y
+ 2)-(LUPAC
+ 12, Y
+ 14), 14, B
MB1 = 0
'driving down arrow
IF MY
>= Y
+ TextHeight
* (TBA2
(nr
).H
- 2) AND MY
<= 12 + Y
+ TextHeight
* (TBA2
(nr
).H
- 2) THEN LINE (LUPAC
- 1, Y
+ TextHeight
* (TBA2
(nr
).H
- 2))-(LUPAC
+ 11, 12 + Y
+ TextHeight
* (TBA2
(nr
).H
- 2)), &H44FFFFFF, BF
LINE (LUPAC
- 1, Y
+ TextHeight
* (TBA2
(nr
).H
- 2))-(LUPAC
+ 11, 12 + Y
+ TextHeight
* (TBA2
(nr
).H
- 2)), 14, B
MB1 = 0
'driving right arrow on bottom
LINE (LUPAC
, ABY
)-(LUPAC
+ 12, ABY
+ 12), &H44FFFFFF, BF
LINE (LUPAC
, ABY
)-(LUPAC
+ 12, ABY
+ 12), 14, B
B = B + 1
MB1 = 0
'driving left arrow on bottom
IF MX
>= X
- 27 AND MX
<= X
- 15 THEN '12 + 15 = 27, 12 is arrow width LINE (X
- 27, ABY
+ 1)-(X
- 15, ABY
+ 13), &H44FFFFFF, BF
LINE (X
- 27, ABY
+ 1)-(X
- 15, ABY
+ 13), 14, B
B = B - 1
MB1 = 0
'new: left - right keyboard driving: (home, end, pg up, pg dn, insert (not edit), delete (not edit), arrows up, down, left, right)
CASE 20224: B
= RowLen
- TBA2
(nr
).L
+ 1 CASE 18688: B
= B
- TBA2
(nr
).L
' PgUP CASE 20736: B
= B
+ TBA2
(nr
).L
' PgDN CASE 19200: B
= B
- 1 ' left CASE 19712: B
= B
+ 1 ' right CASE 18432: BH
= BH
- 1 ' up CASE 20480: BH
= BH
+ 1 ' down CASE 20992: BH
= BH
+ TBA2
(nr
).H
'insert CASE 21428: BH
= BH
- TBA2
(nr
).H
'delete
IF BH
< TBA2
(nr
).I_s
THEN BH
= TBA2
(nr
).I_s
IF BH
> TBA2
(nr
).I_e
THEN BH
= TBA2
(nr
).I_e
IF B
> RowLen
- TBA2
(nr
).L
+ 1 THEN B
= RowLen
- TBA2
(nr
).L
+ 1
TBA2(nr).B = B ' B is variable for shift left and right
TBA2(nr).BH = BH ' BH is variable for shift up and down
IF TBA2
(nr
).filter
= 0 THEN CString k
(), nr: TBA2
(nr
).filter
= 1 'and this is row, which AGAIN find me STRING BUG. Nr is not correct, if is STRING without star used!
BHE = BH + TBA2(nr).H - 2
IF BHE
> TBA2
(nr
).I_e
THEN BHE
= TBA2
(nr
).I_e
'coloring and printing content
'first line invalid color bug repair
IF k
(t
).row
< BH
THEN kkk~&
= k
(t
).clr
IF k
(t
).flag
= nr
THEN ' here is repaired color bug. w = w + 1
w = 0
TBA2(nr).init = 1
FOR rows
= TBA2
(index
).I_s
TO TBA2
(index
).I_e
source$ = GlobalText(rows)
old$ = t$
K
(kk
).clr
= VAL(colornr$
): D
= D
+ LEN(colornr$
): colornr$
= "": incolor
= 0 IF old$
= "/" THEN text$
= text$
+ old$
D = D + 1
incolor = 1
K(kk).onpos = S - D
K(kk).flag = index
K(kk).row = rows
IF incolor
= 0 THEN text$
= text$
+ t$
GlobalText(rows) = text$
text$ = ""
ind = ind + 1
D = 0
CASE 4: D
= 32: CC
= &HFF000000
_PUTIMAGE , img0
, img1
, (W
, 1)-(1, H
) '180 degrees rotating
MaximalRowLenght = 0
ClearColorRecordsAndVauesFromTextArray TBA2(i).I_s, TBA2(i).I_e, test()
IF MaximalRowLenght
< LEN(test
(p
)) THEN MaximalRowLenght
= LEN(test
(p
))
SUB ClearColorRecordsAndVauesFromTextArray
(start
, eend
, arrname
() AS STRING) 'If we need find maximal row lenght, first must color tags be deleted from text. ch$
= MID$(GlobalText
(c
), L
, 1) iscolor = 0
arrname(c - start) = t$
t$ = ""
'End of future "TextBox.BM"