wxwidgets listctrl can't see title when using wxsmith in codeblocks - codeblocks

As the picture shows, you can't find the title which should be "Column 1","Column 2","Column 3"
Here is what I am doing:
In Constructor
ListCtrlRevMsg = new wxListCtrl(this, ID_LISTCTRL1, wxPoint(72,8),wxSize(330,100), wxLC_REPORT, wxDefaultValidator, _T("ID_LISTCTRL1"));
And then, init the columns
wxListItem itemCol;
itemCol.SetText(wxT("Column 1"));
itemCol.SetImage(-1);
itemCol.SetWidth(100);
itemCol.SetTextColour(*wxRED);
ListCtrlRevMsg->InsertColumn(0, itemCol);
itemCol.SetText(wxT("Column 2"));
ListCtrlRevMsg->InsertColumn(1, itemCol);
itemCol.SetText(wxT("Column 3"));
ListCtrlRevMsg->InsertColumn(2, itemCol);
I can't find the reason.

I find the reason:
itemCol.SetImage(-1);
because i don't init the images, when i remove this sentence,it works fine.

Related

QComboBox style for icon image in drop-down list

It is very small that my icon Image in drop-down of combobox.
This problem is happening on Mac.
There was no problem on Windows.
I tried various methods, but I could not solve it.
Please tell me what is wrong.
Simplify:
QComboBox* combobox = new QComboBox(ui.parentWidget);
combobox->setStyleSheet("background-color: white;");
combobox->setIconSize(QSize(WIDTH, HEIGHT));
QString name = "testImage";
QString path = "~/testImage";
combobox->addItem(QIcon(path), "", name);
setStyleSheet() may be bad, but it couldn't be fixed by rewriting.
List of things to try:
enlarge the image itself
write stylesheet width, min-width, implicitWidth and fillmode
setSizePolicy()
setSizeAdjustPolicy()
setPalette()
setSize() for pixmap

Vaadin Image in a Grid not showing

I'm trying to display a tiny little image (16x16 pixels) in a TreeGrid Column.
treeGrid.addComponentColumn(i -> new Image("file://c:/temp/reddot.png", "alt")).setHeader("Preview");
In my IDE, this file url is underlined, I can click it, it opens the image in my browser. So, the file seems ok and exists.
But somehow, it does not appear in the grid column and the "alt" text doesn't appear either.
Hm. Anyone any idea what's going wrong ? Unfortunatly I don't see any error messages...
thanks,
Thorsten
PS: I'm using Version 13.
You could try to put image under META-INF/resources. Then you could reference image directly by name like this : Image im=new Image("kissa.jpg","Random picture");
Otherwise, you could create a inside and then reference mentioning also folder. In the picture below I have this set-up
And this is the output :
The whole code:
TreeGrid<Person> grid = new TreeGrid<>(Person.class);
grid.setHierarchyColumn("name");
grid.addComponentColumn(e->{
if(e.getName().equals("daughter")) {
Image im=new Image("test/cat.jpg","Random picture");
im.setWidth("200px");
im.setHeight("150px");
return im;}
else {
Image im=new Image("kissa.jpg","Random picture");
im.setWidth("200px");
im.setHeight("150px");
return im;}}).setHeader("Cat");
Person dad = new Person("dad", null);
Person son = new Person("son", dad);
Person daughter = new Person("daughter", dad);
List<Person> all = Arrays.asList(dad, son, daughter);
all.forEach(p -> grid.getTreeData().addItem(p.getParent(), p));
add(grid);
The example of TreeGrid is copied from here: Using new features with the LTS version: case TreeGrid

NSButton won't let me set imagePosition property

I'm trying to build a menubar application in swift. I want to set an image and text for the status item. Evidently NSStatusItem has deprecated setting a custom view since 10.10, which is fine, since I am able to set an image and text on the status item's button. However, I'm unable to set the imagePosition property for some reason and so the text and the image overlap.
This is my code:
let statusItem = NSStatusBar.systemStatusBar().statusItemWithLength(-1)
func applicationDidFinishLaunching(aNotification: NSNotification) {
let icon = NSImage(named: "statusIcon")
icon!.setTemplate(true) // best for dark mode
statusItem.button!.image = icon
statusItem.button!.imagePosition = ImageLeft
statusItem.button!.title = "Hello, world"
statusItem.menu = menu;
}
The problem is that Xcode gives me an error on this line:
statusItem.button!.imagePosition = ImageLeft
It says "Use of unresolved identifier 'ImageLeft'", but from what I can tell from the documentation (https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSCell_Class/index.html#//apple_ref/c/tdef/NSCellImagePosition) that is the identifier I would want to use.
Can anyone help?
I figured it out. Evidently I have much to learn about Swift syntax.
This line allows it to work:
statusItem.button!.imagePosition = NSCellImagePosition.ImageLeft

How can i get textView in the scrolledWindow?

i am using ruby-gtk. There is a notebook in my application. I added textView to scrolledWindow. I want to get textView buffer. My some code
editor = Textview.new
swin = Gtk::ScrolledWindow.new
tab = Gtk::Notebook.new
swin.add(editor)
tab.append_page(swin, Gtk::Label.new("Tab")
tab.get_nth_page(current_page).buffer # wrong because its contain is a scrolledWindow
How can i get editor buffer?
As GtkScrolledWindow is a GtkBin, you can make use of child method to get the widget added as the child. In your case it should return GtkTextView. Try something on the lines of:
tab.get_nth_page(current_page).child.buffer
Hope this helps!

How to wrap labels and left align them to the right

I have this code
HorizontalPanel hp = new HorizontalPanel();
hp.setWith("100%");
hp.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
hp.add(new Label("label 1"));
hp.add(new Anchor("anchor 1"));
hp.add(new Label("label 2"));
hp.add(new Anchor("Anchor 2"));
RootPanel.get().add(hp);
Actually it displays
label1...........................................anchor1......................................label2..................................anchor2
I actually wanted something like
label1 anchor1 label2 anchor2
Is there a layout for that or other solution ?
thx
You can keep your HorizontalPanel, but try this:
HorizontalPanel hp = new HorizontalPanel();
hp.setHorizontalAlignment(HasAlignment.ALIGN_LEFT);
hp.setSpacing(2); // 2 = number of pixels between each item
hp.add(new Label("label 1"));
hp.add(new Anchor("anchor 1"));
hp.add(new Label("label 2"));
hp.add(new Anchor("Anchor 2"));
RootPanel.get().add(hp);
All you really needed was a setSpacing property so they're not literally attached to the next cell in your hp, and to remove the hp.setWidth("100%"). If you were doing this in UiBinder, you could keep the 100% width and set the width of each <g:cell> independently, allowing more flexibility.
Also, I suggest you use HasAlignment over HasHorizontalAlignment and/or HasVerticalAlignment, if for no other reason than HasAlignment is portable to all types of panels.
Try FlowPanel. It simply adds widgets from left to right, no spacing, and wraps at the end of the line.
Maybe I'm missing something. It there something more to the layout that you want?

Resources