Beijer Electronics (formerly QSI Corporation)

Manufacturer of Mobile Data and Human Machine Interface Terminals.
It is currently Sun Nov 19, 2017 3:28 am

All times are UTC - 7 hours




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: Listbox Text Wrap?
PostPosted: Thu Nov 15, 2012 6:21 am 
Offline

Joined: Thu Nov 15, 2012 1:38 am
Posts: 7
I'm using the G70 and the listboxV2 add on by opto. I want to display a string table that's about 1000 characters wide and 150 lines long without having to scroll left and right. Is there a way to wrap the text that's off screen to the next line? Right now I've got it scrolling up and down fine, just some lines have text off the right side of the screen.


Top
 Profile  
 
 Post subject: Re: Listbox Text Wrap?
PostPosted: Thu Nov 15, 2012 10:13 am 
Offline
User avatar

Joined: Thu Mar 02, 2006 2:12 pm
Posts: 487
Location: Salt Lake City, Utah
The listbox doesn't support multi-line text, however with some modifications to that object (as a template), it should be possible. I've attached an example to get you started.


Attachments:
multi_line_listbox.zip [11.56 KiB]
Downloaded 219 times

_________________
Ron L.

http://www.beijerelectronicsinc.com/
Top
 Profile  
 
 Post subject: Re: Listbox Text Wrap?
PostPosted: Thu Nov 15, 2012 7:52 pm 
Offline

Joined: Thu Nov 15, 2012 1:38 am
Posts: 7
Sorry i'm not very good with scripts. I'm doing my best using what literature i find online. I tried using the multi-line code in PacListBoxV2 in the 4 locations you used it in your template. My PacListBox is using a tag for a string table. With the 4 lines modified in the basic ListBox library it just cuts off the text on my PacListBox instead of continuing it onto the next line. Can your fix still work with what I'm doing?


Top
 Profile  
 
 Post subject: Re: Listbox Text Wrap?
PostPosted: Fri Nov 16, 2012 8:59 am 
Offline
User avatar

Joined: Thu Mar 02, 2006 2:12 pm
Posts: 487
Location: Salt Lake City, Utah
The PACListBox inherits from the ListBoxV2. Any changes you make should be to a template copy of the ListBoxV2.

Do NOT change any code in the libraries directly. You should be using Templates.

To create a template go to Edit->Add/Edit Templates->New Template->Copy the code of existing..

_________________
Ron L.

http://www.beijerelectronicsinc.com/


Top
 Profile  
 
 Post subject: Re: Listbox Text Wrap?
PostPosted: Wed Nov 28, 2012 5:31 am 
Offline

Joined: Thu Nov 15, 2012 1:38 am
Posts: 7
It works! Thanks for the help Ron! I created a template of the basic ListBoxV2 then copied in your multiline code. Then i created a template of the PacListBox which extended that. What shows on the screen is limited to the minimum height. If I set the min height to 60 the G70 will display 5 rows worth of text from one line of the table. Which is great! However, the lines with only a few words then have 4 rows of blank space before the next set of text. Is there a way for the height to be automatic based on the length of the string table line? Ideally I'd like each line of the table to have one blank line between them when displayed. Thanks again for the assist!


Top
 Profile  
 
 Post subject: Re: Listbox Text Wrap?
PostPosted: Wed Nov 28, 2012 7:46 am 
Offline
QSI Support
QSI Support
User avatar

Joined: Wed Mar 08, 2006 12:25 pm
Posts: 881
Location: Salt Lake City, Utah
The listbox will probably never support variable height lines without a complete rewrite. The editbox based suggestion I made may be a better choice for what you are describing that you want.

_________________
Jeremy
http://www.beijerinc.com


Top
 Profile  
 
 Post subject: Re: Listbox Text Wrap?
PostPosted: Thu Nov 29, 2012 5:30 am 
Offline

Joined: Thu Nov 15, 2012 1:38 am
Posts: 7
Jeremy, I tried implementing the edit box using the bit of code you provided. The text did wrap nicely, but each line from the string table wouldn't start on the next line of the display. Also, both options limit me to 250 elements from the tables when I really need close to double that.


Top
 Profile  
 
 Post subject: Re: Listbox Text Wrap?
PostPosted: Thu Nov 29, 2012 8:05 am 
Offline
QSI Support
QSI Support
User avatar

Joined: Wed Mar 08, 2006 12:25 pm
Posts: 881
Location: Salt Lake City, Utah
To insert a line between each element you would modify your loop like this
Code:
for i = 0 to max
    EditBox_1.appendText = _GetString(i, strings, indexes) + "\n"
next


This will insert a line after each element in the list.

As far as the 250 element limitation goes, that was a limitation in the communication protocol itself. This can be overcome, albeit with some difficulty by using two virtual variable objects, each bound to a different section of the table and a pair of global string variables. Imagine the following:

Code:
'Global Code here
dim tablePart1 as string
dim tablePart2 as string


Code:
' Event handler in the OptoVirtualVarible object which queries index 0-249
func QueryStringTableSucceeded(queryID as integer, strings as string, indexes[] as integer)
    'This approach is the easiest to demonstrate.  There are more efficient ways to tackle this
    'if performance becomes an issue.
    dim i as integer
    dim max as integer
    max = len(indexes)-1
    TablePart1=""
    for i = 0 to max
        TablePart1 = TablePart1 + _GetString(i, strings, indexes) + "\n"
    next

    EditBox_1.value = TablePart1 + TablePart2
endfunc


Code:
' Event handler in the OptoVirtualVarible object which queries index 250-499
func QueryStringTableSucceeded(queryID as integer, strings as string, indexes[] as integer)
    'This approach is the easiest to demonstrate.  There are more efficient ways to tackle this
    'if performance becomes an issue.
    dim i as integer
    dim max as integer
    max = len(indexes)-1
    TablePart2=""
    for i = 0 to max
        TablePart2 = TablePart2 + _GetString(i, strings, indexes) + "\n"
    next

    EditBox_1.value = TablePart1 + TablePart2
endfunc


Now, I will be honest that performance is something I am concerned about when we are dealing with 500 strings that are large enough to wrap lines on a full screen listbox. I hope that this table is not something that gets queried very often. The two performance bottlenecks are: The communication itself and then the repeated string appends may not be the most efficient possible.

_________________
Jeremy
http://www.beijerinc.com


Top
 Profile  
 
 Post subject: Re: Listbox Text Wrap?
PostPosted: Thu Dec 06, 2012 3:43 am 
Offline

Joined: Thu Nov 15, 2012 1:38 am
Posts: 7
Jeremy, everything works great and performance is smooth still! The tables are only queried once when you select that particular display. However, the listbox and editbox when displaying a table default to either the first or last line. In my case those are either very old or blank. Can I set the display to focus on a specific line based on the index that was used to tell the text which line to write to?


Top
 Profile  
 
 Post subject: Re: Listbox Text Wrap?
PostPosted: Thu Dec 06, 2012 7:38 am 
Offline
QSI Support
QSI Support
User avatar

Joined: Wed Mar 08, 2006 12:25 pm
Posts: 881
Location: Salt Lake City, Utah
For the either the editbox or the listbox, use the firstvisrow property to adjust the scroll position.

_________________
Jeremy
http://www.beijerinc.com


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

All times are UTC - 7 hours


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:  
cron
Powered by phpBB® Forum Software © phpBB Group