Tizen native wearable - how to add text label auto line break? - c

I want to show a full line of long text in a label. But when it is small in character numbers It can show it in full. But when the character number grows it shows some part of the texts. Even if I add size to it. It can show line break with html formats but I will perform character operation with network calls, so instead of checking individual characters or keeping track of numbers it will be better if it can add auto line break at the end of screen and show all the texts on screen.
Here's code for label:
ad->label = elm_label_add(ad->conform);
elm_object_text_set(ad->label, "<align=center>Hello Tizen , line is cut offfffffffffffff.</align>");
//elm_object_text_set(ad->label, "<align=center>Hello Tizen <br>testing br</align>");
evas_object_size_hint_weight_set(ad->label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
//elm_object_content_set(ad->conform, ad->label);
evas_object_move(ad->label, 20, 100);
evas_object_resize(ad->label, 300, 300);
evas_object_show(ad->label);
How to add auto line break?

Try using elm_label_line_wrap_set API.
elm_label_line_wrap_set(ad->label, ELM_WRAP_MIXED);
See the API reference below.
void elm_label_line_wrap_set ( Elm_Label *obj,
Elm_Wrap_Type wrap
)
Control the wrapping behavior of the label.
By default no wrapping is done. Possible values for wrap are: ELM_WRAP_NONE - No wrapping ELM_WRAP_CHAR - wrap between characters ELM_WRAP_WORD - wrap between words ELM_WRAP_MIXED - Word wrap, and if that fails, char wrap
https://docs.tizen.org/iot/api/5.0/tizen-iot-headed/group__Elm__Label.html#ga60a1dad4d49a3aea31ced12e30d0b815

Related

How can I increase the size of the displayed text using a library like Allegro? C

How can I change the size of the displayed font to display the following entry:
al_draw_textf(font, al_map_rgb(204, 255, 255), WIDTH / 2, 50,\
ALLEGRO_ALIGN_CENTER, "%d : %d", pl1.scope, pl2.scope);
Created a standard ASCII font which I am trying to resize.
ALLEGRO_FONT* font = al_create_builtin_font();
Display of the players' score. (img)
This is the first game, I didn't do anything except console programs before.
As al_create_builtin_font() - liballeg points out:
ALLEGRO_FONT *al_create_builtin_font(void)
Creates a monochrome bitmap font (8x8 pixels per character).
This font is primarily intended to be used for displaying information
in environments or during early runtime states where no external font
data is available or loaded (e.g. for debugging).
In order to resize fonts load fonts from the local/system repo.
al_load_font() :
ALLEGRO_FONT *al_load_font(char const *filename, int size, int flags)
Package your fonts with the game, it becomes easier to load them.

How to add space in WordPress post content without adding a new line

I have a google sheets document with content that goes into a WordPress post. I am trying to add non-breaking space inside the formulas. The problem is that when I add the non-breaking space I need to create it on a new line. Example:
This is random text which I need to break (Doesn't work)
This works
This is random text which I need to break
If I break the text with the above and below text, the google sheets formula wraps the entire text inside double quotation marks, something I want to avoid. Also, adding this between text doesn't create space where the entity has been added.
In short, what I am looking for is a way to create non-breaking blank space between two sentences where appears. So that this random text here becomes this
So that this random
now breaks and leaves a blank space like so
My google sheets formula is something like this but you don't have to use it ="<h1>"&CONCATENATE(UPPER(A2 &" and " &C2)&" This is Random text")&"</h1><b>"&UPPER(A2 &" and " &C2)&"</b>"&A1&"Date: "&TEXT(BT2,"dddd, dd MMMM yyyy")&"<br>Examples at "&B2&" NOW <b>"&A2&"</b> vs <b>"&C2&"</b> for "&A1&" time period.
Link to google sheets document https://docs.google.com/spreadsheets/d/1qdyMPqbIg6tUOOPrHDoVqzHpQKQhLh4_BT8IhsjE2ig/edit?usp=sharing
Any ideas please?
try:
=REGEXREPLACE("<h1>"&UPPER(A2&" and "&C2)&" This is Random text"&
"</h1><b>"&UPPER(A2&" and "&C2)&"</b>"&A1&"Date: "&TEXT(BT2, "dddd, dd MMMM yyyy")&
"<br>Examples at "&B2&" NOW <b>"&A2&"</b> vs <b>"&C2&"</b> for "&A1&" time period.",
"( )", CHAR(10)&"$1")
to avoid wrapping the copied string into double quotes use:
={""; REGEXREPLACE("<h1>"&UPPER(A2&" and "&C2)&" This is Random text"&
"</h1><b>"&UPPER(A2&" and "&C2)&"</b>"&A1&"Date: "&TEXT(BT2, "dddd, dd MMMM yyyy")&
"<br>Examples at "&B2&" NOW <b>"&A2&"</b> vs <b>"&C2&"</b> for "&A1&" time period.",
"( )", CHAR(10)&"$1")}
one step further would be entering the cell before copying it...
select cell
press ENTER
press CTRL + A
press CTRL + C

How do I allow a "SPACE" character in an AutoComplete JavaFX uneditable ComboBox?

When I type a SPACE character in an AutoComplete ComboBox, I can get the space character to be accepted except the addEventFilter code I'm using to manage it multiplies and inserts a space for each character previously typed prior to the space. You can see a screen shot example below where 3 spaces were added after the 3 characters (ive), then 4 spaces added after I include an additional charater (t), each after typing a single SPACE, and the spaces only appear after I type the next character (e.g. 'm').
I did try this with the ContolsFX AutoComplete, but it cannot handle the uneditable ComboBox - and couldn't find anything to the contrary. In the online cases I research, it was recommended to use the ComboBox's popup skin - addEventFilter to manage the SPACE character event. In nearly all the cases it was to consume() and prevent the space from selection and closing. I did not find anything that strictly allowed the space to be entered. I've tried adding the SPACE in code prior to and after this Event Code but the addEventFilter event.consume() will remove it. The SPACE character will only appear if I manage its addition within the addEventFilter method. I've tried different events such as KeyEvent.ANY, KeyEvent.KEY_TYPED, and KeyEvent.KEY_RELEASE and read the documentation on the KeyEvent, but only KeyEvent.KEY_PRESSED seems to allow the SPACE character, it just multiplies the number of spaces, and doesn't insert until the next text character.
ComboBoxListViewSkin cbSkin = cbSkin = new ComboBoxListViewSkin(cmb);
// cmb is the ComboBox
cbSkin.getPopupContent().addEventFilter(KeyEvent.KEY_PRESSED, (event) -> {
if(event.getCode() == KeyCode.SPACE){
filter += " ";
event.consume();}
});
I was able to solve my problem. The event code needed to be a part of the ComboBoxAutoComplete constructor and not part of the onKeyPressed event.
private ComboBoxListViewSkin cbSkin;
public ComboBoxAutoComplete(ComboBox<T> cmb) {
this.cmb = cmb;
cbSkin = new ComboBoxListViewSkin(cmb);
originalItems = FXCollections.observableArrayList(cmb.getItems());
cmb.setOnKeyPressed(this::handleOnKeyPressed);
cmb.setOnHidden(this::handleOnHiding);
cmb.setSkin(cbSkin);
cbSkin.getPopupContent().addEventFilter(KeyEvent.KEY_PRESSED, (event) -> {
if(event.getCode() == KeyCode.SPACE){
filter += " ";
event.consume();}
});
}

clear text field using DELETE or BACK SPACE key in webdriver

I am trying to clear a text field using this action:
emailField.sendKeys("gmail.com");
emailField.sendKeys(Keys.CONTROL,"a",Keys.DELETE);
In above code, the last line only selects the text, does not delete it, but if I separate the actions it works.
emailField.sendKeys(Keys.CONTROL,"a");
emailField.sendKeys(Keys.DELETE);
From the JavaDoc for WebElement.clear():
If this element is a text entry element, this will clear the value.
Has no effect on other elements. Text entry elements are INPUT and
TEXTAREA elements. Note that the events fired by this event may not be
as you'd expect. In particular, we don't fire any keyboard or mouse
events. If you want to ensure keyboard events are fired, consider
using something like sendKeys(CharSequence) with the backspace key. To
ensure you get a change event, consider following with a call to
sendKeys(CharSequence) with the tab key.
Most likely you simply need to call:
emailField.sendKeys("gmail.com");
emailField.clear();
But if you need the clearing to be done via the keyboard for some reason, use Keys.BACKSPACE.
keys.DELETE can not work to delete the input text,you should use keys.BACKSPACE.
emailField.sendKeys(Keys.BACKSPACE)
From the JavaDoc for Keys.chord
chord(java.lang.CharSequence... value)
Simulate pressing many keys at once in a "chord".
You should be able to use
emailField.sendKeys(Keys.chord(Keys.CONTROL,"a",Keys.DELETE));
Tested in chrome driver
WE.send_keys(' \b')
This will add space then delete it (backspace)
I use in javascript and it's working fine:
await textBox.sendKeys(value);
await textBox.sendKeys(Key.BACK_SPACE);
emailField.sendKeys(Keys.BACKSPACE)
doesn't worked for me .
I used 'Key' instead of 'Keys'
emailField.sendKeys(protractor.Key.BACKSPACE)
emailField.sendKeys(Keys.CONTROL + "a",Keys.DELETE);
In PHP:
if you use php-webdriver (https://github.com/php-webdriver/php-webdriver) you must:
use Facebook\WebDriver\WebDriverKeys AS Keys;
.
.
.
$this->driver->findElement(By::id('demo'))->sendKeys([Keys::BACKSPACE,'Any other text']);
Just adding another working C# example using the Google Chrome webdriver.
SendKeys only takes one parameter so created a string with the Crtl + A. This code sequence will select the current text in the field then delete the text.
Code example:
var crtlA = Keys.Control + "a";
driver.FindElement(By.XPath("//div[3]/div[1]/div[2]/div/div[2]/div[2]/div/div/div[1]/div/span/input")).SendKeys(crtlA); Wait(5000); // Select current text
driver.FindElement(By.XPath("//div[3]/div[1]/div[2]/div/div[2]/div[2]/div/div/div[1]/div/span/input")).SendKeys(Keys.Delete); Wait(5000); // Clear current text
driver.FindElement(By.XPath("//div[3]/div[1]/div[2]/div/div[2]/div[2]/div/div/div[1]/div/span/input")).SendKeys(newItemSku); Wait(5000); // Input SKU name
1. in WebdriverIO, i tried to edit the text by clear text (which contains special charactes like #, +, _) in text field by below following step. Eventhough it was not successful.
example: text=> abc+1234#gmail.com
step1:browser.clearElement(selector);
step2:browser.execute(function () {
document.querySelector(>>>Cssselector<<<).value="";
});
step3: browser.doubleClick(selector);
browser.keys("Delete");
step4: browser.click(selector);
browser.keys(['Meta',a]);
browser.keys('Meta');
browser.keys('Delete');
Note: below step is resolved this issue.
var count= browser.getAttribute(selector, value).length;
for (var i=0;i<count;i++)
{
if (browser.getAttribute(selector, value)=='')
break;
}
else
{
browser.doubleClick(selector);
browser.keys("Delete");
}
browser.pause(200);
// it will clear your text field easily.
Note:
You can add the new text now.

Custom heightForRowAtIndexPath (CGSize sizeWithFont) with NSAttributedString iOS

I have a table view where my cells height is defined dynamically depending on the text it is representing.
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
//getting my text for this cell, the row etc ...
...
//here is the part interesting us
NSAttributedString* theText = [myTextForThisCell objectAtIndex:indexPath.row];
NSInteger labelWidth = self.tableView.bounds.size.width-HORIZONTAL_CELL_PADDING;
CGSize textSize = [theText sizeWithFont:[UIFont systemFontOfSize:customFontSize] constrainedToSize:CGSizeMake(labelWidth, MAXFLOAT) lineBreakMode:NSLineBreakByWordWrapping];
return textSize.height+VERTICAL_CELL_PADDING;
}
Ok so now my problem.
The tableview is the result of a search action which after scanning a plist file shows the lines containing a given string.
Up to now that was it. But now with iOS 6 and NSAttributedString allowing easily to bold part of strings I decided to bold the search word.
It is working, it bolds the words I want but now I am no more able to calculate the cell height as sizeWithFont ask for a NSString. And as bolding takes a wider width I cannot simply calculate the cell height with the string without attributes.
I am simply stuck here.
Anyone can help me ?
In fact I simply had to read apple documentation of NSAttributedText.
In my case I have to replace the last two lines of code by
CGRect rectSize = [theText boundingRectWithSize:CGSizeMake(labelWidth, MAXFLOAT)
options:NSStringDrawingUsesLineFragmentOrigin context:NULL];
return rectSize.size.height+VERTICAL_CELL_PADDING;
FOLLOW UP iOS 7
I have been struggling making this work in iOS7 with attributed text.
Apple documentation says
In iOS 7 and later, this method returns fractional sizes (in the size
component of the returned CGRect); to use a returned size to size
views, you must use raise its value to the nearest higher integer
using the ceil function.
Which way obviously not working for me ! For me the solution was to add +1 to the ceil of height. This is probably a bug from Apple, but for me now everything works as in iOS6.
CGRect rectSize = [theAttributedText boundingRectWithSize:CGSizeMake(labelWidth, MAXFLOAT)
options:NSStringDrawingUsesLineFragmentOrigin context:NULL];
return ceil(rectSize.size.height) + 1 + VERTICAL_CELL_PADDING;

Resources