Sunday, July 29, 2018

Digest for comp.lang.c++@googlegroups.com - 5 updates in 3 topics

jacobnavia <jacob@jacob.remcomp.fr>: Jul 29 11:30PM +0200

My computer?
 
I love it thin, very thin.
 
Elegant, it has a loooooook that kills everyone at the office.
 
How nice, slim, modern, light, ready to be carried in your big pockets
since it is, of course, over-priced and under-clocked.
 
Unable to cool it because of its stupid design, apple hardware like the
new Macbook pro starts GREAT and is incredible fast... the first 3-4
minutes. But under any heavy load (and sometimes even without it) it
must be throttled down (underclocked) to avoid a meltdown.
 
A meltdown like the fated Samsung phone, that caught fire everywhere and
was an industrial accident of huge proportions. I promess to you, I did
not laugh.
 
:-)
 
But it was somehow comic, excuse me.
 
It was thin, bigest screen, biggest CPU etc. It was aesthetically
correct but... caught fire sometimes!
 
Or the Mac Pro 2013, that had the same problem, happily it was so
overpriced that I couldn't afford it. Some years later an Apple engineer
admitted that they had "painted themselves in a thermal corner".
 
But it had a GREAT look, one user reported that his grandmother filled
it with water thinking it was some flower pot.
 
Aesthetically correct hardware for trendy users with big pockets that
doesn't work, but that's not so important. It looks great.
 
For heavy use, if you want the screaming fast CPU at full speed, buy a
big machine that can evacuate the heat produced by your brand new CPU.
 
For instance you can impress your friends with a liquid cooled machine
(the tubes are iluminated in green or red to better impress them). That
big machine will make them understand that they are talking to a real geek.
 
Happily for me, those machines are over-clocked but also over-priced. I
can't afford them.
 
So, I have to limit myself to low end gaming PCs that do not impress
anyone. I try to find some relief with the fact that my machines are
just as fast as the gamer ones, except the "special effects" of course.
 
But the CPU is screaming fast, never under-clocked because of heat
problems. And they are quite cheap, available everywhere...
 
This is another sign of the triumph of form over functionality. Of looks
over substance, an example of our time.
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Jul 29 02:48PM +0200

I started with the FLTK GUI framework for the little thing I'm
hobby-working on at the moment on. But then I discovered that the main
widget I needed, a tree view, was nowhere to be found in FLTK, although
there had been a version with that widget (which google found
initiallly, which is why I felt confident enough to just start coding
with FLTK).
 
So I switched to wxWidgets as portable GUI framework, because Qt has
that decidedly uncute preprocessing, a custom language dialect.
 
I remembered from some 10-15 years ago, whatever, that wxWidgets has a
problem with global variables and the static initialization order
fiasco. That hasn't bitten me yet, but there was a problem with its main
header including `<windows.h>` in Windows. That's a lot of macros! Like
a zillion. Also it did it in a way that produced a compilation error
within some Windows header dragged in by <windows.h>. The solution: to
define `WIN32_LEAN_AND_MEAN`.
 
Also, I discovered, `_UNICODE` (not just `UNICODE`) needs to be defined
to make the wxWidgets environment detection scheme work.
 
Oh, and there was an issue with <wx/setup.h>, which is not found via the
ordinary general include path, but requires its own special include
path, down in [wxWidget root]/lib/vc_lib/mswu. Not a bad idea for
configuration. But it wasn't so clearly documented. I think tutorials
should explain things like that. The critical showstopper things.
 
Even with those fixes the example "Hello, world!" code I found in the
short-short tutorial at <url:
http://docs.wxwidgets.org/stable/overview_helloworld.html> didn't build
as a Windows console program. Uh oh, no `main` function! So what should
go in `main` for a wxWidgets app?
 
For that i dived into the macros that didn't quite work, and hopefully
reproduced the same code execution via `main`. wxWindows appears to be
built of macros, a very very 1990s approach. It so far appears very
MFC-ish, including "message maps" for mapping events to handlers.
 
For the release version in Visual Studio I linked with wxbase31ud.lib,
wxmsw31ud_core.lib, wxpng.lib, wxzlib.lib, kernel32.lib, user32.lib,
gdi32.lib, comdlg32.lib, comctl32.lib and rpcrt4.lib, which appears to
be minimal, roughly.
 
Anyway here's my result code, the tutorial's code fixed so that it
works, and re-styled to more like my code (he he), a working wxWindows
"Hello, world!" for Windows:
 
 
-----------------------------------------------------------------------
#include <stdlib/extension/type_builders.hpp> //
https://github.com/alf-p-steinbach/Wrapped-stdlib
using namespace stdlib::ext::type_builders;
 
// The following two macros defined by <wrapped-windows/windows-h.hpp>:
// WIN32_LEAN_AND_MEAN avoids dragging in buggy part of <windows.h>
// _UNICODE makes wxWidgets macro scheme work.
#include <wrapped-windows/windows-h.hpp> //
#include <wx/wx.h> // Includes <windows.h> :(
 
struct Cmd_id
{
enum Enum
{
hello = 1
};
};
 
class Main_window: public wxFrame
{
void on_cmd_hello( wxCommandEvent& )
{
wxLogMessage( "Hello world from wxWidgets!" );
}
 
void on_cmd_exit( wxCommandEvent& )
{
Close( true );
}
 
void on_cmd_about( wxCommandEvent& )
{
wxMessageBox( "This is a wxWidgets' Hello world sample",
"About Hello World", wxOK | wxICON_INFORMATION );
}
 
wxDECLARE_EVENT_TABLE();
 
public:
Main_window( const wxString& title, const wxPoint& pos, const
wxSize& size ):
wxFrame( nullptr, wxID_ANY, title, pos, size )
{
const ptr_<wxMenu> file_menu = new wxMenu;
file_menu->Append( Cmd_id::hello, "&Hello...\tCtrl-H",
"Help string shown in status bar for this menu
item");
file_menu->AppendSeparator();
file_menu->Append(wxID_EXIT);
const ptr_<wxMenu> help_menu = new wxMenu;
help_menu->Append( wxID_ABOUT );
const ptr_<wxMenuBar> menu_bar = new wxMenuBar;
menu_bar->Append( file_menu, "&File" );
menu_bar->Append( help_menu, "&Help" );
SetMenuBar( menu_bar );
CreateStatusBar();
SetStatusText( "Welcome to wxWidgets!" );
}
};
 
wxBEGIN_EVENT_TABLE( Main_window, wxFrame )
EVT_MENU( Cmd_id::hello, Main_window::on_cmd_hello )
EVT_MENU( wxID_EXIT, Main_window::on_cmd_exit )
EVT_MENU( wxID_ABOUT, Main_window::on_cmd_about )
wxEND_EVENT_TABLE()
 
class App: public wxApp
{
public:
auto OnInit()
-> bool override
{
const ptr_<Main_window> window =
new Main_window( "Hello World", wxPoint( 50, 50 ), wxSize(
450, 340 ) );
window->Show();
return true;
}
};
 
// wxIMPLEMENT_APP(App);
wxIMPLEMENT_WX_THEME_SUPPORT // Does nothing in Windows. :(
 
auto main()
-> int
{
wxDISABLE_DEBUG_SUPPORT(); // Don't know why, but that's in
wxIMPLEMENT_APP.
wxApp::SetInitializerFunction( []() -> ptr_<wxAppConsole> { return
new App; } );
return wxEntry(); // Undocumented, uses process arguments.
}
-----------------------------------------------------------------------
 
 
Cheers!,
 
- Alf
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Jul 29 03:05PM +0200

On 29.07.2018 14:48, Alf P. Steinbach wrote:
> wxmsw31ud_core.lib, wxpng.lib, wxzlib.lib, kernel32.lib, user32.lib,
> gdi32.lib, comdlg32.lib, comctl32.lib and rpcrt4.lib, which appears to
> be minimal, roughly.
 
Oh, that was for the debug version, sorry. Copy+paste-error.
 
Cheers!,
 
- Alf
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Jul 29 03:42PM +0100

On 29/07/2018 13:48, Alf P. Steinbach wrote:
>     return wxEntry();           // Undocumented, uses process arguments.
> }
> -----------------------------------------------------------------------
 
Alf, why do you think anyone would be interested in this old way of doing
things and the post in general?
 
These days people use Qt (or soon my lib, neoGFX).
 
/Flibble
 
--
"Suppose it's all true, and you walk up to the pearly gates, and are
confronted by God," Bryne asked on his show The Meaning of Life. "What
will Stephen Fry say to him, her, or it?"
"I'd say, bone cancer in children? What's that about?" Fry replied.
"How dare you? How dare you create a world to which there is such misery
that is not our fault. It's not right, it's utterly, utterly evil."
"Why should I respect a capricious, mean-minded, stupid God who creates a
world that is so full of injustice and pain. That's what I would say."
Thomas Kaufmann <tokauf@gmail.com>: Jul 29 07:26AM -0700

Barry: it works. THANK YOU!
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

No comments: