beginner c++ material

What’s the smallest file size for a program the opens a photon window, does some IO (gfx or text) and allows the user to maybe make menu selections and quit via the close button? AND has the C++ source to show how it was done?

I figure a small file size is the result of a fairly small, self contained source file(s). Fingers crossed. :slight_smile:

Well, if you want to use C++ a complete example (using standard QNX tools) would be fairly long. I do have a personal C++ class lib that (if it was used to create a similar app) would be comparable to the Java, perhaps even smaller (but non-portable).

If however, you want to step into the 90’s and use Java (he says ducking ;-), here is a test app that does what you ask.

(please excuse the poor indentation, it is the wacky editor on this site)


import org.eclipse.swt.;
import org.eclipse.swt.widgets.
;
import org.eclipse.swt.events.;
import org.eclipse.swt.graphics.
;

public final class App {
Display display;
Shell shell;
Text txt;
Button btn;
Color blue;

public static void    main(String[] args) {
	new App();
}

public App() {
	display = new Display ();

	shell = new Shell (display);

	txt = new Text(shell, SWT.BORDER);
	txt.setBounds(100,100,100, 20);

	btn = new Button(shell, SWT.PUSH);
	btn.setBounds(100,50,100,20);

	btn.setText("Say Hello");

	btn.addSelectionListener(new SelectionAdapter() {
		public void widgetSelected(SelectionEvent event) {
			if (txt.getText().equals("Hello World!"))
				txt.setText("");
			else
				txt.setText("Hello World!");
		}
	});
blue=display.getSystemColor(SWT.COLOR_BLUE);

Canvas canvas=new  Canvas(shell, SWT.BORDER);
canvas.setSize(400,400);
canvas.setLocation(400,400);
canvas.addPaintListener(new PaintListener() {
    public void paintControl(PaintEvent e) {
        GC gc=e.gc;
        gc.setForeground(blue);
        gc.drawLine(80,20,100,80);
    }
});
        
shell.open ();

GC gc=new GC(canvas);
gc.setForeground(blue);
gc.drawLine(80,20,100,80);
    
	while (!shell.isDisposed ()) {
		if (!display.readAndDispatch ()) display.sleep ();
	}
	display.dispose ();
}

}

There is a bbcode called “code” that you might want to try to wrap your code. Test it out in the Test Forum and see if you like it.

Thanks for the pointer !