Attribute concatenation with multiple Theme Classes in SD app - genexus

I am creating a SD App in GX Ev3, and am working on a list.
I came across a requirement for the App and don't know how to do it.
I have to concatenate some Attributes in a String, but one of them (&Status) has to be Font Bold.
&Status + ', por ' + &User + ' em ' + &Date
Possible results:
'OK, por User1 em 01/07/2014'
'Com problema #5, por User2 em 01/07/2014'
'Por validar, por User3 em 01/07/2014'
How can I do it, so it looks like continuous text?

You can do that by using a variable based on the Html domain, and using HTML formatting for the value (i.e. "<b>OK</b>, por ...").
This will create a WebView to display the text, achieving the effect you want.
However, WebViews are unfortunately more resource-intensive than edits, so using them inside a grid is not recommended. We hope to provide a better solution soon.

I would do the HTML field as matiash suggested
But if you want other solution you could do a User Control that can help you.
In an application we have been developing for iOS we have done this using the NSAttributeString.
https://developer.apple.com/library/ios/documentation/cocoa/reference/foundation/classes/NSAttributedString_Class/Reference/Reference.html
What we did is:
&varUC = "#"+&Status +"# my middle text 1 #" + &User + "# my middle text2 #"+&Date+"#"
In our UC we separated the string by the "#" and we changed the the color and weight of those words, then remove the # when displaying the text.
For Android, we haven't done this yet, but with a quick Google search I think you should use:
how to change text color in the middle of the sentence in android
Doing a User Control for GeneXus Smart Devices is really easy ->
http://wiki.genexus.com/commwiki/servlet/hwikibypageid?15301

You can try using the tag "after" in the definition of the class, but you'll have to split the atribute.
Your best bet is to split the variables on the screen, both with distinct classes:
&Status &Text
&Status = 'OK'
&Text = ', por'+&User+' em '+&date
The css sample below is used to automatically set bold fields and (*) on the label of required fields:
.RequiredDataDescription:after
{
font-size: 11px;
font-weight: bold;
color: #333333;
content:" (*)";
}

Related

Append ellipsis when text in a TextField is not completely displayed, Vaadin 8 & 10

When a TextField cannot display all the text of its contents, I would like an ellipsis (… HORIZONTAL ELLIPSIS) to appear as the last character displayed to indicate to the user that some of the field contents is not visible. Actually, any kind of indicator would be acceptable, ellipsis or otherwise.
➛ Is there such a feature in Vaadin 8 (Framework) or 10 (Flow)?
➛ Is there some workaround or modification I can make to do this? Some CSS trick?
I'm not using v10 but I assume a similar approach as the one below based on v8 should get you the same effect. One thing to note is that, like a ton of other stuff, it depends on the browser you're using, and for IE & Edge (link1 pointing to link2) you need to make the input read-only to have it work, hence the focus/blur listeners in my sample. If you'd like, you can further style the input to make it look like a regular one if disabled, but that's not the main point here.
Code
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;
public class MyEllipsisTextFieldComponent extends VerticalLayout {
public MyEllipsisTextFieldComponent() {
TextField ellipsisTextField = new TextField("Ellipsis", "This is a text field with a custom style that uses ellipsis to display very long and uninteresting texts like this one");
ellipsisTextField.addStyleName("ellipsis");
ellipsisTextField.addFocusListener(event -> ellipsisTextField.setReadOnly(false));
ellipsisTextField.addBlurListener(event -> ellipsisTextField.setReadOnly(true));
ellipsisTextField.setReadOnly(true);
addComponent(ellipsisTextField);
addComponent(new TextField("No ellipsis", "This is a regular text field with a very long and uninteresting text that does not use ellipsis"));
}
}
Theme
.v-textfield-ellipsis {
text-overflow: ellipsis;
overflow: hidden;
}
Result

jQuery UI Multiselect Widget With Images (Eric Hynds Version)

The excellent dropdown jQuery UI Multiselect widget that supports styling via jQuery UI Themeroller still doesn't have support for including images within the drop down rows.
I didn't see any answers to this problem within Stackoverflow yet it seems to be asked regularly in various areas of the internet, so I am giving the answer to this question below..
(ALSO See my FIDDLE Example to see this in action,)
The following is based on an initial idea by 'pdlove' for introducing the use of images within this excellent UI Multiselect for jQuery.
Adding Image support for line items in check box text area is achieved by setting out the selector option rows html like this:
<option value="somevalue" image="yourimage.jpg" class="multSelktrImg">
normal visible text
</option>
I would also add a class control to your style sheet css file to set the image size being rendered in the option line items of the drop down, along with a couple of position settings for the image, label and span text.
In this example I use the class name 'multSelktrImg', so within the css file it would look something like this:
.multSelktrImg span{position: relative;top: 10px;vertical-align: middle;
display: inline-flex;}
.multSelktrImg input {vertical-align: -2px;}
.multSelktrImg img {position: relative;height: 30px;margin: 2px 6px;top: -10px;}
Now for the change in the src/jquery.multiselect.js file
Search for the following matching code around line 130 (depending on what version id of the script you are using):
// build items
el.find('option').each(function( i ){
var $this = $(this),
parent = this.parentNode,
title = this.innerHTML,
description = this.title,
....
ADD the following line above "title = this.innerHTML,":
image = this.getAttribute("image");
so that it looks like this:
// build items
el.find('option').each(function( i ){
var $this = $(this),
parent = this.parentNode,
image = this.getAttribute("image");
title = this.innerHTML,
description = this.title,
Now Search for the following matching code around line 180:
// add the title and close everything off
html += ' /><span>' + title + '</span></label></li>';
....
Replace the code line with the following to allow for rendering of your images:
// add the title and close everything off
html += ' /><span>';
if (image != null) {
html += '<img src="'+image+'" class="multSelktrImg">';
}
html += title + '</span></label></li>';
save the new version of the script src/jquery.multiselect.js file and now the images will appear in the multiselect drop down. Use the 'multSelktrImg' class value to control the size of the image displayed by altering the pixel size for the class in your css file.
In the FIDDLE version, I have altered the minimized version of the jQuery script, and created an initialisation of the Select object.

Arabic font in Web UI and itextsharp

I'm not able to find a reason why my MVC 3 web site shows arabic font correctly and my pdf not.
I use a bliss font in my web site;
#font-face {
font-family: 'blissregular';
src: url('/Fonts/blissregular-webfont.eot');
src: url('/Fonts/blissregular-webfont.eot?#iefix') format('embedded-opentype'),
url('/Fonts/blissregular-webfont.ttf') format('truetype');
font-weight: normal;
font-style: normal;}
All working fine.
After that I want to create the pdf of the output but arabic fonts does not appears.
I've googled and understand that the font must have the arabic character to show up correctly. I've changed to arial font (that contains arabic character) and... pdf worked.
So... How is possible that with bliss font (that does NOT have arabic characters) I see arabic font in web site?
I'm really confused....
thanks a lot to everybody!
For every character your browser encounters it looks for a matching glyph in the current font. If the font doesn't have that glyph it looks for any fallback fonts to see if they have that glyph. Ultimately every browser has a core set of default fonts that are the ultimate fallback. When you specify the font Bliss but use Arabic characters you are probably just seeing your browser's fallback fonts.
PDFs don't work that way. If you say something is using font XYZ then it will try to render it using that font or fail.
The easiest way probably is to just add a font to your CSS that supports those characters.
.myclass{font-family: blissregular, Arial}
If that doesn't work you might need to inject the fonts manually. (Actually, I'm not 100% certain the iText support #font-face, either.) iText has a helper class that can figure things out for you that Bruno talks about it here but unfortunately the C# link isn't working anymore. It's very simple, you just create an instance of the FontSelector class, call AddFont in the order that you want characters to be looked up up in and then pass a string to the Process() method which spits back a Phrase that you can add. Below is basic sample code that shows this off. I apologize for my sample text, I'm English-native so I just searched for something to use, I hope I didn't mangle it or get it backwards.
You'll need to jump through a couple of extra hoops when processing the HTML but you should be able to work it out, hopefully.
//Sample string. I apologize, this is from a Google search so I hope it isn't backward
var testString = "يوم الاثنين \"monday\" in Arabic";
var outputFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Test.pdf");
//Standard PDF setup
using (var fs = new FileStream(outputFile, FileMode.Create, FileAccess.Write, FileShare.None)) {
using (var doc = new Document()) {
using (var writer = PdfWriter.GetInstance(doc, fs)) {
doc.Open();
//This is a font that I know *does not* support Arabic characters, substitute with your own font if you don't have it
var gishaFontPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "gisha.ttf");
var gishaBaseFont = BaseFont.CreateFont(gishaFontPath, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
var gishaFont = new iTextSharp.text.Font(gishaBaseFont, 20);
//Add our test string using just a normal font, this *will not* display the Arabic characters
doc.Add(new Phrase(testString, gishaFont));
//This is a font that I know *does* support Arabic characters
var arialFontPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "ARIALUNI.TTF");
var arialBaseFont = BaseFont.CreateFont(arialFontPath, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
var arialFont = new iTextSharp.text.Font(arialBaseFont, 20);
//Create our font selector specifying our most specific font first
var Sel = new FontSelector();
Sel.AddFont(gishaFont);
Sel.AddFont(arialFont);
//Have the font selector process our text into a series of chunks wrapped in a phrase
var newPhrase = Sel.Process(testString);
//Add the phrase, this will display both characters
doc.Add(newPhrase);
//Clean up
doc.Close();
}
}
}

Issue with algorithm to shorten sentences

I have a webpage which displays multiple textual entries which have no restriction on their length. They get automatically cut if they are too long to avoid going to a new line. This is the PHP function to cut them:
function cutSentence($sentence, $maxlen = 16) {
$result = trim(substr($sentence, 0, $maxlen));
$resultarr = array(
'result' => $result,
'islong' => (strlen($sentence) > $maxlen) ? true : false
);
return $resultarr;
}
As you can see in the image below, the result is fine, but there are a few exceptions. A string containing multiple Ms (I have to account for those) will go to a newline.
Right now all strings get cut after just 16 characters, which is already very low and makes them hard to read.
I'd like to know if a way exists to make sure sentences which deserve more spaces get it and those which contain wide characters end up being cut at a lower number of characters (please do not suggest using the CSS property text-overflow: ellipsis because it's not widely supported and it won't allow me to make the "..." click-able to link to the complete entry, and I need this at all costs).
Thanks in advance.
You could use a fixed width font so all characters are equal in width. Or optionally get how many pixels wide every character is and add them together and remove the additional character wont the pixel length is over a certain amount.
If the style of your application isn't too important, you could simply use a font in the monospace family such as Courier.
Do it in Javascript rather than in PHP. Use the DOM property offsetWidth to get the width of the containing element. If it exceeds some maximum width, then truncate accordingly.
Code copied from How can I mimic text-overflow: ellipsis in Firefox? :
function addOverflowEllipsis( containerElement, maxWidth )
{
var contents = containerElement.innerHTML;
var pixelWidth = containerElement.offsetWidth;
if(pixelWidth > maxWidth)
{
contents = contents + "…"; // ellipsis character, not "..." but "…"
}
while(pixelWidth > maxWidth)
{
contents = contents.substring(0,(contents.length - 2)) + "…";
containerElement.innerHTML = contents;
pixelWidth = containerElement.offsetWidth;
}
}
Since you are asking for a web page then you can use CSS text-overflow to do that.
It seems to be supported enough, and for firefox there seems to be css workarounds or jquery workarounds...
Something like this:
span.ellipsis {
white-space:nowrap;
text-overflow:ellipsis;
overflow:hidden;
width:100%;
display:block;
}
If you fill more text than it fits it will add the three dots at the end.
Just cut the text if it is really too long so you don't waste html space.
More info here:
https://developer.mozilla.org/En/CSS/Text-overflow
Adding a 'see more' link at the end is easy enough, as appending another span with fixed width, containing the link to see more. text will be truncated with ellipsis before that.

Vimperator recommended setting

By way of study of Vim, I have begun to use Vimperator add-on for Firefox recently.
Therefore please teach it if there is recommended setting.
Two settings are extremely useful, at least for me:
:set wildoption=auto
:set cpt=l
You can try them from vimperator command line first. After you type in the first one, you will see dynamic hints immediately, for example, if you continue to try the second command and to see what mean by 'l' . With wildoption on, you access to an item from the hint list by pressing Tab key, instead of arrow keys which would not work in most cases.
Another one I like is to set up my Bookmarks as sidebar by default, the command is:
:sidebar Bookmarks
One more trick after you have wildoptions on, you can access to FireFox menu items by typing:
:emenu [key_word]
# or
:em[tab]
where key_word is any menu key word such as Add-on.
I have several blogs on vimperator and how to set vimperator default settings.
Enjoy Vimperator. It is a great add-on for Firefox.
Skypecakes suggested b and B to switch tabs; I prefer using h and l, since there's a good chance you switch tabs more often than you scroll horizontally:
noremap l gt
noremap h gT
Calling up Vim itself with C-i in a textarea is a must. See here if you have trouble on Windows
set editor="C:/path/to/gvim.exe -f"
This is to customize how hints look in .vimperatorrc. The syntax is CSS, but you can probably figure it out without knowing it as well (I personally increase the font-size):
highlight! Hint font-family: monospace; font-size: 16px; font-weight: bold; text-transform: uppercase; color: white; background-color: red; border-color: ButtonShadow; border-width: 0px; border-style: solid; padding: 0px 1px 0px 1px;
Finally, if you set the working directory you can save URLs to that location with a simple :w<Enter>:
cd C:/Users/GGustafson/Desktop
Not really. One of the remarkable characteristics of Vim (and Vimperator) is providing a pretty decent experience with the default configuration. What I would suggest you to do is to play around with macros (q) and hinting (f), the best, IMHO, features of Vimperator.
There are numerous examples of interesting macros, being my favourite the one that opens all the images on all tabs, each expanding into a new tab with the corresponding images. Try to write it! You'll need just markers and some javascript similar to Pornzilla's "Linked Images"
I'm using Pentadactyl - which is almost the same. I find useful the following two options:
set hintkeys=0123456789abcdefghijklmnopqrstuvwxyz
set! browser.tabs.closeButtons=2
Also - suppose Your FireFox aware of wikipedia search - and suppose it is called wikipedia-en. Then here's a way to bind search selection in wikipedia to a key:
javascript <<EOF
dactyl.mulSearch = function () {
let selection = content.getSelection().toString();
dactyl.execute(":tabopen wikipedia-en " + selection);
};
EOF
:map s -js dactyl.mulSearch();
(You should put this to ~/.pentadactylrc) This search selection after You'll press s. This way You can also bind other search engines - to the same key!
Edit:
" default place for downloads:
cd ~/dwn
" lots of hints!
set hintkeys=0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
" no close buttons on tabs
set! browser.tabs.closeButtons=2
" May be default hints would suit You better - but they were to small for me:
:highlight Hint font:"DejaVu Sans Mono";font-size:120%;color:red;background-color:yellow;padding:2px;
" to prevent d on the last tab from closing the window:
:set! browser.tabs.closeWindowWithLastTab=false
" encripted google - is better for hints (it has less links)
:bmark https://encrypted.google.com/search?sclient=psy&hl=en&complete=0&site=webhp&source=hp&q=%s -keyword google
set defsearch=google
" ==================
"" Cyrillic letters:
map Ф A
map И B
map С C
map В D
map У E
map А F
map П G
map Р H
map Ш I
map О J
map Л K
map Д L
map Ь M
map Т N
map Щ O
map З P
map Й Q
map К R
map Ы S
map Е T
map Г U
map М V
map Ц W
map Ч X
map Н Y
map Я Z
map ф a
map и b
map с c
map в d
map у e
map а f
map п g
map р h
map ш i
map о j
map л k
map д l
map ь m
map т n
map щ o
map з p
map й q
map к r
map ы s
map е t
map г u
map м v
map ц w
map ч x
map н y
map я z
I made some small changes. Made moving between tabs a single keystroke instead of two, since it is the most common thing I do next to clicking links and scrolling.
Also show visual indicator instead of beeping, and show the destination of the selected hyperlink in the command line instead of the status line, so that I can still see the URL of the current page at all times.
From my _vimperatorrc file:
" Mappings
map b gt
map B gT
map a B
" Options
set visualbell
set complete=hbsf
set showstatuslinks=2
I also use Pentadactyl, but the below should work with Vimperator as well. I added several commands to enable searching through different sites like DuckDuckGo and stackoverflow.
You can add a new search engine with the following command:
:display searchengines
Add the stackoverflow search engine to make the below work.
Define a new command stack to search through stackoverflow:
:command -nargs=* stack open stack-overflow <args>
Now you can search through stackoverflow to get all vimperator related questions with the following command:
:stack vimperator
Make sure to issue
:mkpentadactylrc!
to make the command available after a restart of Firefox.
"eval script in tabs
js <<EOF
function ExecScriptInTabs(filter,domjs){
tabs.allTabs.forEach(function(itm){
var ctab=gBrowser.getBrowserForTab(itm);
if(filter(ctab)){
var s=ctab.contentDocument.createElement('script')
s.textContent=domjs;
ctab.contentDocument.body.appendChild(s);
}
})
}
EOF
then you can mapping what you want
group.mappings.add(
[modes.NORMAL],
[",ds"],"skip",
function(){
ExecScriptInTabs(function(ctab){
return ctab.contentDocument.location.host.match("douban\.fm");
},"DBR.act('skip')");//skip,pause,love
}
)
If you want to save session when using Alt+F4 or qall command
Add following line to your ~/.vimperatorrc
command! qall xall

Resources