Why some functions are so difficult to find. I would like to have some controls without the restrictions for using...this or that themes..manifests or other bad habits..
So i wrote some textboxes. All of them are based in glist (latest edition).
Here I have a TextViewer to display text with line spacing as we wish and wrapping or not. The only limitation is has no drag and drop,and not for this version undo control.. Because is the glist behind this TextViewer can scroll the text holding down the mouse button and doing a move anywhere in the window of the glist
I also have some textboxes with one line only
- a Combobox with auto complete function (shows/hide a listbox of values)
- a Spinner Textbox for a long value. We can alter the value by clicking and writing, by using up down buttons, by using the scroll bar.
- a simple textbox wit centered text that can be edit ...as is, we can use it without edit, just showing text
- a button that can be slide the caption and perform the "click" (by panning right) (2 buttons using here, one to alter the wrapping of the textViewer, and the other to show/hide the paragraphs marks..
- A floating list of values to put in Spinnet TextBbox. We can "call" like a popup menu. See above the spinner textbox, when you right click.
Version 2
- ComboBox - works fine.
- CheckBox
- Info popup in a textbox demonstration
for document type
- Simple undo (undo for deleted marked text and for paragraph changes), use control Z
- Control A (select all)
- Double click select word
- Drag and Drop
you can move or copy from and to same document. double click a marked text show the drag icon. This is not the same as holding down the mouse and move. This function is for moving like using a stick the scroll bar.
Last Version
This version is almost identical to the one before. When we mark text a up or down movement of caret (or cursor) unmark the text. A second touch is about the showing of scrollbar. It was a small appearance of that scroll bar when showing the form who hold the control, that it isn't pretty, especially for that glists where the items are less or equal of viewing lines. A last touch was for document (textviewer class) for the example with file selector, a missing +1 chenage the line for caret in a drag over event when no header used (drawing) in the glist.
For the Selector Example.
Open Load File Selector and open a txt file (UNICODE or not). A new form opens with one text box (the standard one) and one from textviewer class (a wrapper class for glist4 listbox control). From file menu check enable to write and check the other options to see what happen. Also the textviewer resize as we resize the window, and the wrapping is fast, very fast (enable it from file menu). Also see that classic textbox has flickering. No flickering for Textviewer.
If anyone want the scroll bar only, then that code can be found it in Scrollio example, (I wrote the scroll bar for the scrollio control, as an image/drawing viewer, and then I do a merge of that code to the glist, the one with ...millions of items...that I posted here some months ago).
I have started the major task to, and I have exclude file,folder, color and font selectors from M2000 Environment and Interpreter, and now is time to through the classic textbox.
That's All
...for now
Last edited by georgekar; Nov 2nd, 2014 at 04:27 PM.
Reason: Advance Unicode Keyboard
Re: Nice Textboxes version2.1 Plus Varius Selectors
A change in MyDoc for real fast reading of text (not in the zip files above)
Code:
Property Let textDoc(norawtext As String)
Dim where As Long
Dim a() As String
where = 1
a() = Split(norawtext, vbCrLf)
norawtext = Join(a(), vbLf)
If InStr(norawtext, vbLf) = 0 Then
AppendParagraph norawtext
Else
a() = Split(norawtext, vbLf)
For where = LBound(a()) To UBound(a())
AppendParagraph a(where)
Next where
End If
End Property
Re: Nice Textboxes version2.1 Plus Varius Selectors
So I through old replacestr (something i used in Vb5)
I post here a crop from a screen shot, when I have opened the redist.txt from C:\Program Files\Microsoft Visual Studio 1.33Mbyte (non unicode). Look the number of lines in the caption of form.
Last edited by georgekar; Sep 25th, 2014 at 06:39 PM.
Reason: Sorry my english are poor...
Re: Nice Textboxes version2.1 Plus Varius Selectors
New Version for the two examples..
some error founded in sliding option on selectors (an error that happen to come in a later version...that was a nightmare...
Whats new?
I put SelText SelLength and SelStart to act as in a Textbox to the TextViewer class (with additions to the MyDoc class, which holds paragraphs). The very difficult routine is the FindPos...where from a line in the view window and a cursor from that..we can found the exact position in the text without render the mydoc class to a string holding all the document (so no copy of a big text needed). In myDoc class we hold paragraphs and for each paragraph we hold lines. And we didn't hold cr & lf the two characters for changing paragraph in MS. Before the SelText and Sellength..the Selstart showing the paragaph cursor. Now that change to ParaSelStart. Before the implementation of SelText, Sellength and SelStart, the textviewer works happily by making the mark text by arrows and or mouse. That could happen because the marked text have internal variables as start line and start pos and endline and endpos, plus the paragraphs id and paragraph cursors...Also from the last 4 variables if we resize the viewing window we can recalculate easily the other for values. So with all those variables...sellength and selstart not needed...until we wish to handle the TextViewer document as string.
Let say that we have in Form1 the document as TextViewer and we have a document of at least 100 chars
Form1.document.SelStart=100
Form1.document.SelText="Inserted Text"
Form1.document.SelStart=100
Form1.document.SelLengrh=3
Form1.document.SelText="XXX"
So now we replace "Ins" with "XXX"
We can do that and the text can automatic do any wrapping and moving in the viewing window
if sellength is not 0 then we can make it zero with that
Form1.document.SelText=""
The selText always make the selection visible scrolling the window if needed
so if sellength=0 we can scroll to visible, the 1000th char
Form1.document.SelStart=1000
Form1.document.SelText="" ' just this do the job. without place or delete anything (sellength=0)
some other goodies (from previous versions)
Form1.document.glstn.listcount is the number of lines (with wrapping if we set it on)
Form1.document.glstn.list(0) is the first line
Form1.document.glstn.listindex = 10 ' we select line 11
Form1.document.glstn.selstart =4 ' this is the line cursor
Form1.document.glstn.showme ' always visible the listindex and the selstart of glist
Form1.document.glstn.showme2 ' redraw without scrolling.
glistn is setting using container property
In a form
Public WithEvents document As TextViewer
in form_load
Set document = New TextViewer
Set document.Container = gList1
document.Filename = "" ' needed to initialize the mydoc class inside TextViewer ' we can give a filename there
In the unload event
document.Dereference ' needed or not is better to not hold references
Set document = Nothing
Mydoc Class has an event to ask for breaking a line..
TextViewer get that event and use the glistN own breaking routine. If anyone like can change that for do a better routine (the glist routine break to spaces and slashes \)
Thats All...
(I am going to change M2000 Interpreter to use glist extensively, for lists and textboxes to varius selectors)
Re: Nice Textboxes version2.1 Plus Varius Selectors
Some changes..I do the import to M2000 interpreter (now I have to make the help file, an mdb file for english).
In M2000 i replace the textbox with textviewer & glist
Here are some events for glst1, the control that is the container of textviewer (class)
Code:
Private Sub gList1_ChangeListItem(item As Long, content As String)
If nochange Then
nochange = True
mn1.Enabled = TEXT1.SelLength > 1
mn2.Enabled = TEXT1.SelLength > 1
mn3.Enabled = Clipboard.GetFormat(13) Or Clipboard.GetFormat(1)
sdn.Enabled = TEXT1.SelLength > 0 And (Len(TEXT1.Text) - TEXT1.SelStart) > TEXT1.SelLength
sup.Enabled = TEXT1.SelLength > 0 And TEXT1.SelStart > TEXT1.SelLength
nochange = False
End If
End Sub
Private Sub gList1_ChangeSelStart(thisselstart As Long)
If gList1.Enabled Then
mn1.Enabled = TEXT1.SelLength > 1
mn2.Enabled = TEXT1.SelLength > 1
mn3.Enabled = Clipboard.GetFormat(13) Or Clipboard.GetFormat(1)
sdn.Enabled = TEXT1.SelLength > 0 And (Len(TEXT1.Text) - TEXT1.SelStart) > TEXT1.SelLength
sup.Enabled = TEXT1.SelLength > 0 And TEXT1.SelStart > TEXT1.SelLength
End If
End Sub
Private Sub gList1_KeyDownAfter(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyTab Then
KeyCode = 0
End If
End Sub
Private Sub gList1_MarkOut()
mn1.Enabled = TEXT1.SelLength > 1
mn2.Enabled = TEXT1.SelLength > 1
mn3.Enabled = Clipboard.GetFormat(13) Or Clipboard.GetFormat(1)
sdn.Enabled = TEXT1.SelLength > 0 And (Len(TEXT1.Text) - TEXT1.SelStart) > TEXT1.SelLength
sup.Enabled = TEXT1.SelLength > 0 And TEXT1.SelStart > TEXT1.SelLength
End Sub
Private Sub gList1_SyncKeyboard111(KeyAscii As Integer)
If KeyAscii = 9 Then KeyAscii = 0: Exit Sub
If KeyAscii = 13 Then KeyAscii = 0: Exit Sub
End Sub
' so here I have the popup menu...
Private Sub gList1_OutPopUp(x As Single, Y As Single, myButton As Integer)
wordwrap.Checked = Not TEXT1.NoWrap
wdrag.Checked = TEXT1.glistN.DragEnabled
Form1.PopupMenu Form1.aaaa, , x + gList1.Left, Y + gList1.Top
myButton = 0
End Sub
Private Sub gList1_KeyDown(KeyCode As Integer, Shift As Integer)
Static ctrl As Boolean, noentrance As Boolean, where As Long
Dim aa$, a$
mn1.Enabled = TEXT1.SelLength > 1
mn2.Enabled = TEXT1.SelLength > 1
mn3.Enabled = Clipboard.GetFormat(13) Or Clipboard.GetFormat(1)
Select Case KeyCode
Case vbKeyReturn '
nochange = True
KeyCode = 0
If TEXT1.SelLength > 0 Then TEXT1.SelText = ""
Dim ii As Long, JJ As Long
ii = TEXT1.SelStart
JJ = rinstr(Left$(TEXT1.Text, TEXT1.SelStart), vbLf)
If JJ >= 0 Then JJ = JJ + 1
If JJ > 0 Then
ii = Len(Mid$(TEXT1.Text, JJ)) ' ii is all text from first char in the cursor line
ii = ii - Len(LTrim$(Mid$(TEXT1.Text, JJ))) ' Now ii= the spaces of ii
If ii > 0 Then
JJ = ii Mod 6
ii = (ii \ 6)
If ii = 0 Then
ii = JJ
Else
ii = ii * 6
End If
JJ = TEXT1.SelStart + ii + 2 ' selstart + 2 for vbcrlf + ii spaces
TEXT1.Text = Mid$(TEXT1.Text, 1, TEXT1.SelStart) + vbCrLf + Space$(ii) + LTrim$(Mid$(TEXT1.Text, TEXT1.SelStart + 1))
TEXT1.SelStart = JJ
Else
JJ = TEXT1.SelStart
TEXT1.Text = Mid$(TEXT1.Text, 1, TEXT1.SelStart) + vbCrLf + Mid$(TEXT1.Text, TEXT1.SelStart + 1)
TEXT1.SelStart = JJ + 2
End If
Else
JJ = TEXT1.SelStart
TEXT1.Text = Mid$(TEXT1.Text, 1, TEXT1.SelStart) + vbCrLf + Mid$(TEXT1.Text, TEXT1.SelStart + 1)
TEXT1.SelStart = JJ + 2
End If
nochange = False
Case vbKeyControl
ctrl = True
KeyCode = 0
Case vbKeyF1
If (Shift And 2) = 2 Then
If TEXT1.SelText <> "" Then
helpme_Click
Else
vHelp
End If
Else
TEXT1.NoWrap = Not TEXT1.NoWrap
TEXT1.Render
End If
KeyCode = 0
Case vbKeyF2
If TEXT1.SelText <> "" Then sup_Click
KeyCode = 0
Case vbKeyF3
If TEXT1.SelText <> "" Then sdn_Click
KeyCode = 0
Case vbKeyF12
mn5_Click
KeyCode = 0
Case vbKeyTab
nochange = True
gList1.Enabled = False
JJ = TEXT1.SelStart
where = JJ
ii = rinstr(vbCrLf + Mid$(TEXT1.Text, 1, JJ), vbCrLf, 1) - 1 ' -2+1
If TEXT1.SelLength > 0 Then
JJ = TEXT1.SelLength + JJ - ii
TEXT1.SelStart = ii
TEXT1.SelLength = JJ
JJ = where
Else
TEXT1.SelStart = ii
End If
If TEXT1.SelText <> "" Then
a$ = vbCrLf + TEXT1.SelText + "*"
If Shift <> 0 Then ' âãÜëå
a$ = ReplaceStr(vbCrLf + Space$(6), vbCrLf, a$)
TEXT1.SelText = Mid$(a$, 3, Len(a$) - 3)
TEXT1.SelStart = ii
TEXT1.SelLength = Len(a$) - 3
Else
a$ = ReplaceStr(vbCrLf, vbCrLf + Space$(6), a$)
TEXT1.SelText = Mid$(a$, 3, Len(a$) - 3)
TEXT1.SelStart = where + 6
TEXT1.SelLength = Len(a$) - 3 - (where + 6 - ii)
End If
Else
If Shift <> 0 Then
If Mid$(TEXT1.Text, JJ + 1, 6) = Space$(6) Then
TEXT1.Text = Left$(TEXT1.Text, JJ) + Mid$(TEXT1.Text, JJ + 7)
TEXT1.SelStart = ii
End If
Else
TEXT1.SelStart = JJ
TEXT1.SelText = Space(6)
TEXT1.SelStart = where + 6
End If
End If
gList1.Enabled = True
TEXT1.Render
nochange = False
Case Else
ctrl = False
End Select
End Sub
Private Sub gList1_KeyDownAfter(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyTab Then
KeyCode = 0
End If
End Sub
The good parts are in keydown event. Tab and shift tab make indent to a block of lines (or one line). Return key add spaces so code can be written in each line with the same space in left.
(these functions works with the ordinary textbox, and now works with textviewer)
TextViewer is better than textbox, can hold very big documents, have drag and drop, and also a line spacing (using glist.addpixels property). The latest version use the enabled property, as false, to prevent redrawing when much of usage of seltext and sellegth happens.
In the textboxes4_1 example the spinner textbox need a textbox1.Enabled = True in the form load event if we want to edit by using keyboard writing the number. Without textbox1.Enabled = True only for the myTextBox class as a spinner..we can get in or get out with tab and shift tab and also we can alter the value with up and down arrows. But how we can see if we are in that control when no caret show??
We can use these events... using the container glistN property backcolor and redraw with ShowMe
Private Sub textbox1_GotFocus()
textbox1.glistN.BackColor = RGB(255, 255, 255)
textbox1.glistN.ShowMe
End Sub
Private Sub textbox1_LostFocus()
textbox1.glistN.BackColor = RGB(200, 120, 60)
textbox1.glistN.ShowMe
End Sub
Re: Nice Textboxes version2.1 Plus Varius Selectors
For document in the same example:
document.LineSpacing = 16 ' pixels to add in each line ' text are vertical centered by default for TextViewer, so 8 pixels up and 8 pixels down space in each line
document.EditDoc = True ' we need that to make the document editable (this false and NoMark true to scroll without alter the text, NoMark=true mark a paragraph in any line height.)
document.SetRowColumn 1, 0
' before enabled=true so we hide the caret...(1,0 move the caret to row and column 1,1 for displaying in caption..this was changed from some versions...before. Why? because column 1 has two positions for caret 0 for the left position and 1 for the right. The ParaSelStart - selstart in some previus versions- start from 1 when caret is in 0 position and in first line in the paragraph. So dislayed coordinates by info event are according to paragraph base 1, and the line numbers are base 1 too.
document.Enabled = True ' so now we enable the control
document.Show ...and just show it.
TextViewer has no Locked property (the enabled property does the job)
MyTextBox has a Locked Property and Enabled property... Locked property is the reverse of enabled property of a TextViewer or a glist. No output can drawn. The Enabled property of a myTextBox is a gEditFlag of the container glist. So Enabled in a myTextBox means...we can edit by keyboard, and we see the caret.
TextViewer has no Locked function because a locked condition not needed to stay but only for a short time we need to not redraw the control and that can be handled by Enabled property. What we like is to see the text without alter it, so that can be done with two ways. We have the EditDoc flag and the NoMark Flag
EditDoc=True, NoMark=False ' we edit as normal textbox multiline
EditDoc=True, NoMark=True ' We can mark text, scroll anywhere, but we can't alter the text by keyboard
EditDoc=False, NoMark=False ' We can scroll the text only.
EditDoc=False, NoMark=True ' We can scroll the text and mark the current paragraph (wrapping or not, do as you wish ..)
Because under TextViewer is a glist we have the stickbar option on, so we can scroll to the direction we move mouse as holding down the left mouse button, in an accelarating manner. When we press shift for the Textviewer only, we have an alternate function (basically glist just make for that short time the stickbar act as not enabled), we mark the text as we move the mouse.
To mark text we have 3 ways. One by double click in the text and move the mouse inside the marked text. We can unhold the mouse and later we can expand the marked text, just hold and move the mouse on top of market text. Every time the caret is on the expanded size (up or down...or change direction). Second by using keyboard and Shift. Third is by using mouse and shift (no double click needed).
Marked text also be unmakred if we use arrows without shift.
Ctrl + A select all...and Ctrl+Shift+A unmark text.
A double click in a word automark that work (if no mark text exist). A click in any position except the marked text...unmark the text.
For dragging the text: Needed marked text and a double click on it...(second double click disable drag). Draging not needed to hold down the mouse button. We can change to cut or copy...(automatic cut for inside movement and copy for outside...) using shift. We can "break" the drag using escape or placing the caret inside the marked text (no copy or cut and then paste done in same place).
By default TextViewer allow drag and drop operations. We can change that using glist property DragEnabled and DropEnabled.
So for document we give document.glistN.DragEnabled = False
a MyTextBox not allow cut and paste or drag and drop operations. We can use the a popupmenu and handle the vartext (the text without left and right constantlly showing text). The constantlly showing text are part of glist. In the spinner control the right text is the unit indicator "mm" and the prompt say "Variable X=". For the ComboBox the right indicator is the letters that automatic added. Just see what happen in the code..It is a beautiful code...
Unlimited Undo and Redo in a document- work fine with drag and drop.
Was very difficult to program. The document class use glist a control and mydoc to put the document. I change the old undo-redo and I use the new seltext, sellenght and selstart properties of document class.
I give here only the textboxes example. Also I put a new checkbox to demonstrate how we can switch to editable value in spinner textbox or just leave it to change by scroll bar and arrow keys and by software.
(have some bugs...in undo-redo, so not consider it as a final "stage")
Last edited by georgekar; Oct 16th, 2014 at 11:09 AM.
Reason: bugs
Here is screenshot from Ubuntu Studio
(some fonts have substitutes in linux and for that reason bold can't enabled...so we have to give an exist fontname in linux to enable bolds..)
I found many bugs related to undo-redo...and I integrate it to M2000 interpreter (I have to write help files in English and fix some dialog with nice texboxes from this code)
Also I want to colorize code (I do this in gedit box before but I would like to do with glist)
I found that in Linux-Wine the form control (and the user control in glist cannot get chars with ' like ά). I think this is a Wine problem. I can copy or drag an ά (alfa) but when a press button for ' and then the char nothing happen..somewhere the final character..disappear. I also note that notepad in Wine has no such problem.
Also note that glist write unicode chars, so glist can be used for russian or other (left to right) language. (The code is open and free for use, so anyone can study it and perform a right to left editor...I can't do that because I can't verify the output, I didn't know how to edit in a right to left editor...)
Some things altered here. First a bug from SelStart property (only for the last line...I have forged to wrote a minus one). Second I release the drag to any other control or a wordpad with move by using alter button (also we can copy, by default). Drag and drop and copy and past use unicode and simple text pass (both are used here). Font changed to Arial at the command buttons (all the controls in textboxes use the glist as container). BorderStyle changed to 1 for those controls with header to look better...(we can change this anytime) The two controls with header are float controls, we can move them anywhere in the form.
It is very easy to make listboxes, comboboxes, textboxes, document editors, spinner boxes, command buttons, checkboxes, infoboxes/setupboxes. menus and dorpdown lists. All of them uses only one usercontrol with three shapes only (for creating the auto hidding scroll bar - used also as spinner bar).
The document viewer and editor now has unlimited undo/redo, cut, copy and paste drag and drop, auto selection for word. Why it is better to use this and not a textbox? Because this control has line spacing, and left "margin" space so we can have more clear lines to read, and also we can change word wrapping when we wish, we can scroll up down with or without the scroll bar (auto hide), and when we wave no wrapping we can go left or right without scroll bar...just move the caret to left or right.
Controls from Microsoft as I Know have no line spacing
About my recent work.
Now M2000 Environment use line spacing to produce any text console by a command FORM. FORM 80,25 use all the screen to show 80 chars width by 25 lines height and for the same screen -1280x1024- a FORM 80x48 with 0 linespacing, or FORM 80X60 narrow screen with smaller font size. So I use there the TextViewer class with glist4 as a text editor that fits in that screen as overlay .A console screen in M2000 used for graphics also, and have a scrolling function and a split screen property, that enable the scrolling in a low part of the control. That lower part can become a text editor. With the ordinary text box from Microsoft I couldn't used line spacing, so this is a big improvement. Now my interpreter use no dll except DAO 3.5+ for making and using databases. I replace all the common controls with glist containers (I didn't use listview, so this is not in my scope to make it). File and Folder selector, Font selector, Color Selector. The only form I can't change is the printer properties form...
Last edited by georgekar; Dec 30th, 2014 at 12:15 PM.
Developing M2000, I found minor bugs like in the undo system in TextViewer. It was difficult to found that because the faulty issue came up when we do three copies from the text and in specific direction
This was the test text
I would like to cut 22 and paste right from 66, then cut 6622 and paste right to 44
So when I press ctrl + Z...and after a second press then the problem happen, corruption of text (a star is deleted and no 22 is going in position, in second line)
Now not only we can go back with ctrl+Z but we can go front (after we went back) with ctrl+Y.
Now I do the correction. Also I do the same for drag and drop too.
MyDoc class is the newest one. Has word count and save and load Unicode (UTF-8 included).
All of these classes are in M2000 code revision 13 (isn't uploaded yet...)