When I use code formatting with MonoDevelop (Shortcut: Ctrl+I), everything gets double-indented:
namespace Example
{
public class Test
{
public static void Main(string[] args)
{
for (int i = 0; i < 10; i++)
{
Console.WriteLine("{0}: Test", i);
}
//this would be the desired indentation width!
//Not this!
}
}
}
Checking with the preferences under Source Code -> Code Formatting -> C# source code under Text Style, Tab width and Indent width are set to 4. Nevertheless, I get an indent width of 8 instead of 4, so twice as much indentation.
I'm working on a team-project with Unity3D and using MonoDevelop-Unity version 4.0.1.
It turned out that the solution/project itself had a different code formatting applied and it was overriding my settings from the preferences.
To adjust the solution/project specific settings, right click on the Solution/Project and choose Options. Under Source Code->Code Formatting->C# source are the actual tab width and indent width settings for this solution/project that are applied upon code formatting.
Related
I want to control the TabPane and switch tabs with a Canvas, basically hide the tab headers and use canvas instead, the canvas displays different "Devices" and when user click on the device, the TabPane switch to show the content of that device.
fun canvasFlow_Click(mouseEvent: MouseEvent) {
val d = flowPresenter.click(mouseEvent)
if (d != null) {
flowPresenter.select(d)
logger.info("switch to ${d.position}")
tab.selectionModel.clearSelection()
tab.selectionModel.select(d.position)
}
}
Why select doesn't work? I don't see tab content changed. from log, I see "switch to 1", "switch to 2" correctly, just the tab doesn't switch! Why?
Note: this is plain javafx and might not be the exact solution in your case (hard to tell without example) - but actually I can reproduce the described behavior.
The problem seems to be calling clearSelection: TabPane with tabs should have exactly one selected tab - which is not specified. But every internal collaborator (skin, header, listener) goes to great lengths to guarantee that constraint - this assumption was wrong, in fact the skin gets confused if the selection changes to empty - the previously selected content is not removed. Might be a bug, either don't allow the selectionModel to be empty or improve the skin to cope with it (wondering how that would be supposed to look - hide the content?)
Anyway, here the solution is to not call that method before manually selecting a tab. There's no need to do so anyway, it's a SingleSelectionModel so takes care of allowing at most one item selected.
An example: un/comment the clearSelection and see how the content is not/ correctly updated with/out the call.
public class TabPaneSelection extends Application {
private Parent createContent() {
TabPane pane = new TabPane();
HBox headers = new HBox();
for (int i = 0; i < 3; i++) {
int index = i;
Tab tab = new Tab("header " + i, new Label("content " + i));
pane.getTabs().add(tab);
Button button = new Button(tab.getText());
button.setOnAction(e -> {
// do __not__ clear selection
//pane.getSelectionModel().clearSelection();
pane.getSelectionModel().select(index);
});
headers.getChildren().add(button);
}
BorderPane content = new BorderPane(pane);
content.setTop(headers);
return content;
}
#Override
public void start(Stage stage) throws Exception {
stage.setScene(new Scene(createContent(), 400, 300));
//stage.setTitle(FXUtils.fxVersion());
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
I'm using a single wxButton:
wxButtonAction::wxButtonAction(wxWindow* parent) : wxButton(parent,wxID_ANY) {
#if defined __WXMSW__
wxIcon ms_icon(wxT("START_ICON"), wxBITMAP_TYPE_ICO_RESOURCE, 16, 16);
wxBitmap button_bmp;
button_bmp.CopyFromIcon(ms_icon);
#else
wxFileName icon_path(DATA_DIR, wxT("start.ico"));
wxBitmap button_bmp(icon_path.GetFullPath(), wxBITMAP_TYPE_ICO);
#endif
SetLabel(_("&Start"));
SetBitmap(button_bmp);
}
The bitmaped button is show as expected. This method helps me change both bitmap and label when user clicks that button:
void wxButtonAction::updateOnAction(bool isRunning) {
#if defined __WXMSW__
wxIcon ms_icon((isRunning) ? wxT("STOP_ICON") : wxT("START_ICON"), wxBITMAP_TYPE_ICO_RESOURCE, 16, 16);
wxBitmap button_bmp;
button_bmp.CopyFromIcon(ms_icon);
#else
wxFileName icon_path(DATA_DIR, (!isRunning) ? wxT("stop.ico") : wxT("start.ico"));
wxBitmap button_bmp(icon_path.GetFullPath(), wxBITMAP_TYPE_ICO);
#endif
SetLabel((!isRunning) ? _("&Stop") : _("&Start"));
SetBitmap(button_bmp);
}
and now the resource file:
AAPP_ICON ICON DISCARDABLE "../data/app.ico"
ABOUT_ICON ICON "../data/about.ico"
CLOSE_ICON ICON "../data/close.ico"
START_ICON ICON "../data/start.ico"
STOP_ICON ICON "../data/stop.ico"
1 24 "../data/manifest.xml"
The label is changed propertly when the user toggle clicking the button, but not the icon is always in "start" bitmap. I can confirm that all icons exists in the same folder
You don't need to use CopyFromIcon() at all, there is an implicit conversion from wxIcon to wxBitmap under MSW (because under the other platforms they're exactly the same thing). This being said, calling it explicitly should still work, so it's not clear what the problem is.
I'd like to recommend two other things: first, prefer using PNG (with real alpha transparency) to ICO nowadays. You might find wxBITMAP_PNG() useful to avoid the preprocessor checks, too.
Second, remove the manifest line from your .rc file and add #include "wx/msw/wx.rc" instead. This will do the right thing for the manifest and also define other stuff needed by wxWidgets applications.
I have added fontawesome in my projects of Xamarin.Forms, on UWP font looks as expected but on android it is square. I have set build-action to AndroidAsset but it does not work.
On Android, it's a bit of a hassle use FontAwesome. This code behind post is about how to use Font Awesome in the simplest way possible. It's as easy as using a Label once set up.
We use a custom renderer that looks at the Label in question, determines if there is one character in the text field and if that character has the value of 0xf000 or higher. If so, we replace the font with FontAwesome.
Since the icons all begin at 0xf000 or higher, the custom renderer will make sure that the correct font is used
Reference article
[assembly: ExportRenderer(typeof(Label), typeof(AwesomeRenderer))]
namespace Awesome.Droid
{
public class AwesomeRenderer : LabelRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Label> e)
{
base.OnElementChanged(e);
var label = (TextView)Control;
var text = label.Text;
if(text.Length > 1 || text[0] < 0xf000)
{
return;
}
var font = Typeface.CreateFromAsset(Xamarin.Forms.Forms.Context.ApplicationContext.Assets, "fontawesome.ttf");
label.Typeface = font;
}
}
}
I'm trying to apply GTK+ 3 CSS rules to widgets used in the Eclipse UI, specifically for a ComboBox right now. For example: say I want to make the background color of a selected text in a combobox to be red. The Style rule applied to the combobox widget would be
*.entry:selected { background-color: #FF0000; }
I have proven that rule using the Gtk+ CSS Inspector tool in Ubuntu and that works there but I do not find a way to apply that rule in code for ComboBoxes.
Inside SWT, there are places where CSS is used on Linux, such as this snippet to set the background color, however, adding the above rule to the CSS override does not have any apparent impact (yes, the background color does work).
#Override
void setBackgroundColor (long /*int*/ context, long /*int*/ handle, GdkRGBA rgba) {
// CSS to be parsed for various widgets within Combo
background = rgba;
String css = "* {\n";
if (rgba != null) {
String color = display.gtk_rgba_to_css_string (rgba);
css += "background: " + color + ";\n";
}
css += "}\n";
// Cache background color
cssBackground = css;
String finalCss = display.gtk_css_create_css_color_string (cssBackground, cssForeground, SWT.BACKGROUND);
//Injected code to make selected text red
finalCss += "\n.*:selected {background-color: #FF0000}";
if (entryHandle == 0 || (style & SWT.READ_ONLY) != 0) {
// For read only Combos, we can just apply the background CSS to the GtkToggleButton.
gtk_css_provider_load_from_css (OS.gtk_widget_get_style_context(buttonHandle), finalCss);
} else {
if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0)) {
// For GTK3.16+, only the GtkEntry needs to be themed.
gtk_css_provider_load_from_css (OS.gtk_widget_get_style_context(entryHandle), finalCss);
} else {
// Maintain GTK3.14- functionality
setBackgroundColorGradient (OS.gtk_widget_get_style_context (entryHandle), handle, rgba);
super.setBackgroundColor (OS.gtk_widget_get_style_context (entryHandle), entryHandle, rgba);
}
}
// Set the background color of the text of the drop down menu.
OS.g_object_set (textRenderer, OS.background_rgba, rgba, 0);
}
I’ve tried various combinations of selectors and so far have not found a way to have the “selection” background color of the text to take effect.
Here is a link to the corresponding ComboBox class from SWT where it deals with CSS -- see the setBackgroundColor method.
https://github.com/eclipse/eclipse.platform.swt/blob/master/bundles/org.eclipse.swt/Eclipse%20SWT/gtk/org/eclipse/swt/widgets/Combo.java
I have proven that code runs and also managed to change the background for the entire combobox by changing the css rule there. However, if I inject my new rule it gets ignored.
Any help would be appreciated. Thanks!
I'm developing an application in javaFx and I'm using TabPane to organise content. My problem is that when I put a node as the content of a tab, and then set the background of that same node, the background color gets kind of blurry, as you can see in the image, the background color was defined in a css file.
If anyone knows how to resolve this, would really appreciate the help.
http://i.stack.imgur.com/h3gNH.png
I think you are a victim of this issue:
JavaFX Image (PNG) transparency crispness being lost when rendering
It will likely be fixed in a forthcoming (i.e. Java 8) release.
For now, you may be able to use the work-around documented in the linked question's answer.
To do this, place your image in a CenteredRegion and use that as the first element of a StackPane placed in your tab. Then layer the rest of the tab content over the image by adding the content to the StackPane. It's a bit awkward and there may be a more straight-forward solution for your particular case.
class CenteredRegion extends Region {
private Node content;
CenteredRegion(Node content) {
this.content = content;
getChildren().add(content);
}
#Override protected void layoutChildren() {
content.relocate(
Math.round(getWidth() / 2 - content.prefWidth(USE_PREF_SIZE) / 2),
Math.round(getHeight() / 2 - content.prefHeight(USE_PREF_SIZE) / 2)
);
}
public Node getContent() {
return content;
}
}