Welcome to the MP3Car.com forums.
You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. Registering will also remove advertisements. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!
If you have any problems with the registration process or your account login, please contact contact us.
|
09-16-2006, 12:20 AM
|
#1
|
|
Low Bitrate
Join Date: Jun 2005
Posts: 77
|
Scrollable Label?
Hey David,
Is it possible to scroll through a label object? Basically I would users to scroll through the text assigned to a label if the data becomes too long to display(Like the Listbox objects) in my plug-in.
I guess that I could figure out how many lines I can fit in the label and then load parts of the string as the down/up arrow is pressed.
I noticed that there is the following in the SDK; I just haven't seen it used in the sample code:
CFControls.skinLabel
needScroll - Label need scrolling flag (Field)
Just wanted to see if you might have a recommendation for this.
|
|
|
09-19-2006, 06:30 PM
|
#2
|
|
Low Bitrate
Join Date: Jun 2005
Posts: 77
|
Any thoughts?
|
|
|
09-19-2006, 09:27 PM
|
#3
|
|
MySQL Error
Join Date: Apr 2004
Posts: 4,953
|
needScroll is a flag you can set to use if you want too... Labels can be created to scroll, but it would have to be programming in on the plugin side currently...
it's not that hard to get a temp variable and scroll the lables you need to scroll, pulling off the text and invalidating the lable area...
david
__________________
__________________
CENTRAFUSE http://www.centrafuse.com
01 Jeep Cherokee Sport 4x4 Installed
M10000/512Mb/20GB, Lilliput 7", Holux GM-210
|
|
|
09-28-2006, 10:33 PM
|
#4
|
|
Low Bitrate
Join Date: Jun 2005
Posts: 77
|
Quote: Originally Posted by veetid 
needScroll is a flag you can set to use if you want too... Labels can be created to scroll, but it would have to be programming in on the plugin side currently...
it's not that hard to get a temp variable and scroll the lables you need to scroll, pulling off the text and invalidating the lable area...
david
Sorry to be a pain but I am not quite sure how to go about this...
I would need to set some kind of limit based off of the label itself in order to determine when the string I am loading into the label is too long and has to be split.
Which properties could I use to accomplish this?
|
|
|
09-28-2006, 10:40 PM
|
#5
|
|
MySQL Error
Join Date: Apr 2004
Posts: 4,953
|
Quote: Originally Posted by JWise1203 
Sorry to be a pain but I am not quite sure how to go about this...
I would need to set some kind of limit based off of the label itself in order to determine when the string I am loading into the label is too long and has to be split.
Which properties could I use to accomplish this?
here you go:
Code:
string text = "new text for the label";
CFControls.skinLabel temp = (CFControls.skinLabel)labelArray[CF_getLabelID("NAMEOFMYLABEL")];
if(text != null)
{
temp.Text = text;
temp.Draw = true;
StringFormat sf = StringFormat.GenericDefault;
sf.FormatFlags |= StringFormatFlags.MeasureTrailingSpaces;
Graphics g = this.CreateGraphics();
int iWidth = (int)g.MeasureString(temp.Text, temp.Font, 0, sf).Width;
if(iWidth > temp.Bounds.Width)
{
//Do What you need to do because the text is too long
}
g.Dispose();
labelArray[CF_getLabelID("MAINTITLE")] = temp;
this.Invalidate(new Rectangle(temp.Bounds.X, temp.Bounds.Y, temp.Bounds.Width, temp.Bounds.Height), false);
}
david
__________________
__________________
CENTRAFUSE http://www.centrafuse.com
01 Jeep Cherokee Sport 4x4 Installed
M10000/512Mb/20GB, Lilliput 7", Holux GM-210
|
|
|
10-01-2006, 08:39 PM
|
#6
|
|
Low Bitrate
Join Date: Jun 2005
Posts: 77
|
Quote: Originally Posted by veetid 
here you go:
Code:
string text = "new text for the label";
CFControls.skinLabel temp = (CFControls.skinLabel)labelArray[CF_getLabelID("NAMEOFMYLABEL")];
if(text != null)
{
temp.Text = text;
temp.Draw = true;
StringFormat sf = StringFormat.GenericDefault;
sf.FormatFlags |= StringFormatFlags.MeasureTrailingSpaces;
Graphics g = this.CreateGraphics();
int iWidth = (int)g.MeasureString(temp.Text, temp.Font, 0, sf).Width;
if(iWidth > temp.Bounds.Width)
{
//Do What you need to do because the text is too long
}
g.Dispose();
labelArray[CF_getLabelID("MAINTITLE")] = temp;
this.Invalidate(new Rectangle(temp.Bounds.X, temp.Bounds.Y, temp.Bounds.Width, temp.Bounds.Height), false);
}
david
I put this code into my plug-in and am having issues with the code thinking the text is out of bounds, when it really isn't.
I have attached an example of what I am trying to do.
I am writing a plug-in for AOL Instant Messenger and I need the label to handle two things:
1. Once the message text becomes to large, automatically scroll the label to show the most current text.
2. Via the up and down buttons, allow the user to scroll the text in the label and read older text not currently displayed on the screen.
Hopefully that is descriptive enough, I have tried to work with the example code, but haven't been able to get things working right.
|
|
|
10-02-2006, 10:16 AM
|
#7
|
|
MySQL Error
Join Date: Apr 2004
Posts: 4,953
|
It's as simple as storing the main string in a variable and only updating the labels text with what can fit...
david
__________________
__________________
CENTRAFUSE http://www.centrafuse.com
01 Jeep Cherokee Sport 4x4 Installed
M10000/512Mb/20GB, Lilliput 7", Holux GM-210
|
|
|
10-02-2006, 10:23 AM
|
#8
|
|
Low Bitrate
Join Date: Jun 2005
Posts: 77
|
Quote: Originally Posted by veetid 
It's as simple as storing the main string in a variable and only updating the labels text with what can fit...
david
Yes, I guess what I was getting at in the last post was the code you posted was telling me the the main string would be out of bounds when in fact it had plenty of room to fit.
I was wondering if the code you provided was for another use ... say for the main song title label scroll.
|
|
|
10-02-2006, 03:42 PM
|
#9
|
|
MySQL Error
Join Date: Apr 2004
Posts: 4,953
|
Quote: Originally Posted by JWise1203 
Yes, I guess what I was getting at in the last post was the code you posted was telling me the the main string would be out of bounds when in fact it had plenty of room to fit.
I was wondering if the code you provided was for another use ... say for the main song title label scroll.
It was, you just asked for an example of how to measure a string I thought... It was just an example, not code to copy/paste and use...
sorry for the misunderstanding...
I can help you write what you need after I get RC4 released...
david
__________________
__________________
CENTRAFUSE http://www.centrafuse.com
01 Jeep Cherokee Sport 4x4 Installed
M10000/512Mb/20GB, Lilliput 7", Holux GM-210
|
|
|
10-07-2006, 07:01 AM
|
#10
|
|
Low Bitrate
Join Date: Jun 2005
Posts: 77
|
David, any chance that you could help me out with this, this weekend?
|
|
|
10-07-2006, 11:44 AM
|
#11
|
|
MySQL Error
Join Date: Apr 2004
Posts: 4,953
|
Quote: Originally Posted by JWise1203 
David, any chance that you could help me out with this, this weekend?
you just have a timer, check the length of the string compared to the length of the text field... truncate off a letter and update the label text in the timer...
there are probably a million examples of doing this style of thing on google, just need to apply to CFPlugin functions, which shouldn't be difficult..
I gave you the .NET code to measure a string with a specified font...
david
__________________
__________________
CENTRAFUSE http://www.centrafuse.com
01 Jeep Cherokee Sport 4x4 Installed
M10000/512Mb/20GB, Lilliput 7", Holux GM-210
|
|
|
11-03-2006, 10:21 PM
|
#12
|
|
Low Bitrate
Join Date: Jun 2005
Posts: 77
|
Ok David,
I haven't gotten a chance to look at this till tonight ... I have gotten the out of bounds exception to work properly by modifying your sample code slightly.
Basically I needed to get the height or area and not just the width of the label rectangle, since I am concerned about the text going going out of bounds vertically.
Code:
string text = strMessage;
CFControls.skinLabel temp = (CFControls.skinLabel)labelArray[CF_getLabelID("MESSAGEWINDOW")];
if(text != null)
{
temp.Text = text;
temp.Draw = true;
StringFormat sf = StringFormat.GenericDefault;
sf.FormatFlags |= StringFormatFlags.MeasureTrailingSpaces;
Graphics g = this.CreateGraphics();
int iWidth = (int)g.MeasureString(temp.Text, temp.Font, 0, sf).Width;
int iHeight = (int)g.MeasureString(temp.Text, temp.Font, 0, sf).Height;
int iArea = iWidth * iHeight;
if(iArea > (temp.Bounds.Width * temp.Bounds.Height))
{
//Do What you need to do because the text is too long
System.Diagnostics.Trace.WriteLine("*************** Caught OOB!!! *****************");
System.Diagnostics.Trace.WriteLine("Text Area: " + iArea);
System.Diagnostics.Trace.WriteLine("Rec Area: " + (temp.Bounds.Width * temp.Bounds.Height));
System.Diagnostics.Trace.WriteLine("*************** Caught OOB!!! *****************");
}
g.Dispose();
labelArray[CF_getLabelID("MAINTITLE")] = temp;
this.Invalidate(new Rectangle(temp.Bounds.X, temp.Bounds.Y, temp.Bounds.Width, temp.Bounds.Height), false);
}
The label is only getting updated when a message is sent or received, not off of a timer.
Now that I have the code working which will fire when the text is out of bounds I have two issues left:
1. When the message text is out of bounds, only display the end of the message (sort of like the ScrollToCarret method for a textbox).
2. Provide the user the ability to scroll through the entire message by pressing up and down arrows.
My question to you is if this can be done through th exposed CF API?
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 03:52 PM.
|
|