How to convert the normal text to bold text? - dialog

I have this code in my Dialog:
//other code
dialog.addText(strFmt("Delete this field's value: %1?", MyTable.FieldTable));
//other code
I have an output looklike:
I know the strUpr function:
dialog.addText(strFmt("Delete this field's value: %1?", strUpr(MyTable.FieldTable)));
Does there exist a method or function to convert only the FIELDValue to bold text?

You can set the bold property to 7 on FormBuildStaticTextControl.
Control can be obtained via the control method on DialogText returned by addText method.
The integer that is returned contains the weight of the font as follows:
0 Use the default font weight.
1 Thin.
2 Extra-light.
3 Light.
4 Normal.
5 Medium.
6 Semibold.
7 Bold.
8 Extra-bold.
9 Heavy.
Example:
Dialog dialog = new Dialog();
DialogText dt = dialog.addText("Test");
FormBuildStaticTextControl txtCtl = dt.control();
txtCtl.bold(7);
dialog.run();

A working example using addFieldValue (similar to Matej's solution):
Dialog dialog = new Dialog("Dialog example");
DialogField f1 = dialog.addFieldValue(extendedTypeStr(String30), 'Value', "Delete this field's value?");
FormBuildStringControl c1 = f1.control();
c1.allowEdit(false);
c1.skip(true);
c1.bold(7);
c1.viewEditMode(ViewEditMode::View);
dialog.run();

I doubt that Dialog class has the ability to display bold text, at least I haven't seen such, neither did I find any method to format text in a dialog. One solution would be to create custom form that looks like a dialog box, but I think it is redundant.
Regarding uppercase, you can use strUpr (link) method:
//other code
dialog.addText(strUpr(strFmt("Delete this field's value: %1?", MyTable.FieldTable)));
//other code

Related

Formatting Strings in TextField JavaFX

In my JavaFX application I am trying to format a String and then push it to TextField.
This is my code:
String result = "No of Rows Returned : " + repairHeaderEntities.size();
if(null!=repairHeaderEntities && repairHeaderEntities.size()>0){
result = result + "\n" + "\nRepair Status Code: "+entity.getRepairStatusCode();
analyzeResult.setText(result);
analyzeResult is the TextField fx id.
But in the output I am getting the following:
No of Rows Returned : 1Repair Status Code: ENDE
As you can see there output is not moving to a new line and is coming up in the same line.
From the documentation for TextField:
Text input component that allows a user to enter a single line of unformatted text. Unlike in previous releases of JavaFX, support for multi-line input is not available as part of the TextField control, however this is the sole-purpose of the TextArea control.
Use a TextArea in place of the TextField.
If you do not want the user to be able to edit the text in the text control, you could also consider using a Label instead.

lwuit text area

I developed an RSS Application for two XML files and displayed it on two LWUIT Tabs. The problem is with my LWUIT TextArea, whenever I click on my ListForm (it contains titles from the RssFile), I need to display description information from the RSS File. First time I am able to display the description related to the title clicked in ListForm. If I click the ListForm the next time onwards I am able to display the same description again and again in the textarea..(Eventhough I am getting Related Description from RssFile)
Here is my Code:
private void displayCompleteNewsScreen(News detailNews) {
Label title = new Label(detailNews.getTitle());
form2.setTitleComponent(title);
String Description = detailNews.getDescription();
System.out.println("Description" + Description);//Here i am able to get different Description values Related to myList Screen but in text area it is displaying First one always
big = new TextArea();
big.setEditable(false);
big.setText(Description);
form2.addComponent(pubDate);
form2.addComponent(big);
form2.show();
}
As you are reusing form2 instance you should clear it in displayCompleteNewsScreen method. Call removeAll before calling setTitleComponent.
And don't forget to set form2 Commands again in displayCompleteNewsScreen.

HowTo: Visio SDK page Re-Layout FlowChart Top to Bottom

I'm creating a dynamic VSD from a hierarchical set of data that represents a flowchart. I don't want/need to fuddle with absolute positioning of these elements - the automatic layout options will work just fine.
The problem is I can't figure out how to perform this command via code. In the UI (Visio 2010), the commands are on the ribbon here: Design (tab) -> Layout (group) -> Re-Layout (SplitButton).
Any of these will do. Looking through the Visio SDK documentation and Googling for a couple days have turned up nothing of very much use.
Any ideas? (using C#, but VB/VBA would do)
The Page.Layout() method itself is not enough.
In the WBSTreeView.sln sample project (VB.Net) I found how to accomplish this, but couldn't post my answer until 8 hours later :-x
The other layout types are possible by looking through the enums used below.
Compact -> DownRight just ended up being better for most of the flows we're creating.
Translated to C#:
// auto-layout, Compact Tree -> Down then Right
var layoutCell = this._page.PageSheet.get_CellsSRC(
(short)VisSectionIndices.visSectionObject,
(short)VisRowIndices.visRowPageLayout,
(short)VisCellIndices.visPLOPlaceStyle);
layoutCell.set_Result(
VisUnitCodes.visPageUnits,
(short)VisCellVals.visPLOPlaceCompactDownRight);
layoutCell = this._page.PageSheet.get_CellsSRC(
(short)VisSectionIndices.visSectionObject,
(short)VisRowIndices.visRowPageLayout,
(short)VisCellIndices.visPLORouteStyle);
layoutCell.set_Result(
VisUnitCodes.visPageUnits,
(short)VisCellVals.visLORouteFlowchartNS);
//// to change page orientation
//layoutCell = this._page.PageSheet.get_CellsSRC(
// (short)VisSectionIndices.visSectionObject,
// (short)VisRowIndices.visRowPrintProperties,
// (short)VisCellIndices.visPrintPropertiesPageOrientation);
//layoutCell.set_Result(
// VisUnitCodes.visPageUnits,
// (short)VisCellVals.visPPOLandscape);
// curved connector lines
layoutCell = this._page.PageSheet.get_CellsSRC(
(short)VisSectionIndices.visSectionObject,
(short)VisRowIndices.visRowPageLayout,
(short)VisCellIndices.visPLOLineRouteExt);
layoutCell.set_Result(
VisUnitCodes.visPageUnits,
(short)VisCellVals.visLORouteExtNURBS);
// perform the layout
this._page.Layout();
// optionally resize the page to fit the space taken by its shapes
this._page.ResizeToFitContents();
//
Changing Connector Line Colors
If you're unfamiliar with how formulas for colors work, this might also be very frustrating. By default you can give an int as a string to get pre-defined colors, but this isn't very helpful because there isn't an easy way to figure out what each of those colors are. (There is a Page.Colors collection, but you have to inspect each of their RGB values and figure out the color from them.)
Instead, you can use your own RGB values for the formula.
private void SetConnectorLineColor(Shape connector, string colorFormula)
{
var cell = connector.get_Cells("LineColor");
cell.Formula = colorFormula;
}
internal static class AnswerColorFormula
{
public static string Green = "RGB(0,200,0)";
public static string Orange = "RGB(255,100,0)";
public static string Yellow = "RGB(255,200,0)";
public static string Red = "RGB(255,5,5)";
}
Call the Layout method on the Page object. If there are shapes selected on this page then this method will only operate on the current selection. You may want to call DeselectAll on the ActiveWindow first.

How to align RIGHT the content of TextArea in LWUIT?

I want to align the text in a TextArea to the right. I tried the following code:
Form form = new Form();
TextArea textArea = new TextArea("Some Arabic text ...");
textArea.setRTL(true);
textArea.setAlignment(RIGHT);
form.addComponent(textArea);
The result was just moving the scroll to left,
But the text is still not aligned RIGHT,
check the image below:
So how to align the content to the RIGHT ?
It may sound crazy for the first instance :) but setting the alignment to TextArea.LEFT solved the issue and now it's RIGHT aligned !
Form form = new Form();
TextArea textArea = new TextArea("Some Arabic text ...");
textArea.setRTL(true);
textArea.setAlignment(TextArea.LEFT);
form.addComponent(textArea);
Setting it to LEFT makes the displayed text RIGHT aligned !
Or by removing the textArea.setRTL(true) which is mirroring the display
Form form = new Form();
TextArea textArea = new TextArea("Some Arabic text ...");
textArea.setAlignment(TextArea.RIGHT);
form.addComponent(textArea);
For those who are interested in more complicated details when it's set to RTL:
the paint method of TextArea class is
public void paint(Graphics g) {
UIManager.getInstance().getLookAndFeel().drawTextArea(g, this);
}
And drawTextArea method in DefaultLookAndFeel is as follows:
int align = ta.getAbsoluteAlignment();
// remaining code is here in initial source
switch(align) {
case Component.RIGHT:
x = ta.getX() + ta.getWidth() - rightPadding - f.stringWidth(displayText);
break;
// remaining code is here in initial source
}
g.drawString(displayText, x, y);
Unfortunately TextArea.RIGHT value is 3
But when calling ta.getAbsoluteAlignment() it returns 1 (despite that the object's alignment is set by code to TextArea.RIGHT !!)
Meanwhile TextArea.Left value is 1
That's why it matched the value in the switch and was aligned to RIGHT
BTW, if you set
textArea.setAlignment(Component.RIGHT);
it will also be wrong, because Component.RIGHT outside the paint method has the value 3 not 1 !
You only have to write 'TextArea.RIGHT' instead of 'RIGHT'
textArea.setAlignment(TextArea.RIGHT);
You can use the following line:
TextArea textArea = new TextArea("Some Arabic text ...");
textArea.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);

C# TableLayoutPanel replace control?

I was wondering if it was possible to replace one control in a TableLayoutPanel with another at runtime. I have a combo box and a button which are dynamically added to the TableLayoutPanel at runtime, and when the user selects an item in the combo box and hits the button, I'd like to replace the combobox with a label containing the text of the selected combo box item.
Basically, if I could simply remove the control and insert another at it's index, that would work for me. However I don't see an option like "splice" or "insert" on the Controls collection of the TableLayoutPanel, and I was wondering if there was a simple way to insert a control at a specific index. Thanks in advance.
Fixed this by populating a panel with the two controls I wanted to swap and putting that into the TableLayoutPanel. Then I set their visibility according to which I wanted to see at what time.
This is what I've been able to come up with for what I needed. It gets the position of the ComboBox and makes a new label using the selected value.
// Replaces a drop down menu with a label of the same value
private void lockDropMenu(ComboBox dropControl)
{
TableLayoutPanelCellPosition pos = myTable.GetCellPosition(dropControl);
Label lblValue = new Label();
myTable.Controls.Remove(dropControl);
if (dropControl.SelectedItem != null)
{
lblValue.Text = dropControl.SelectedItem.ToString();
lblValue.Font = lblValue.Font = dropControl.Font;
// Just my preferred formatting
lblValue.AutoSize = true;
lblValue.Dock = System.Windows.Forms.DockStyle.Fill;
lblValue.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
myTable.Controls.Add(lblValue, pos.Column, pos.Row);
}
}

Resources