Skip to content

Instantly share code, notes, and snippets.

View vadz's full-sized avatar

VZ vadz

View GitHub Profile
@vadz
vadz / profile.h
Created April 27, 2014 16:26
Trivial profiling helper for wxWidgets code
///////////////////////////////////////////////////////////////////////////////
// Name: wx/profile.h
// Purpose: Simple helprs for manually profiling the code.
// Author: Vadim Zeitlin
// Created: 2013-02-22
// RCS-ID: $Id$
// Copyright: (c) 2013 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
@vadz
vadz / gist:176dbe919f4839581ce3
Last active August 29, 2015 14:00
Thread safe (?) way to wait for the main thread
class Thread : public wxThread {
int Entry() override {
for (;;) {
{
lock_guard<mutex> lock(m_mutex);
if (!m_window)
return 0;
m_window->CallAfter(&Window::ProvideResult);
}
@vadz
vadz / wxxrc_catalog.xml
Created April 7, 2015 17:41
Example XML catalog file mapping XRC schema to a local file.
<?xml version="1.0"?>
<!DOCTYPE catalog
PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN"
"http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<uri name="http://www.wxwidgets.org/wxxrc" uri="file:///$WXWIN/misc/schema/xrc_schema.rnc"/>
</catalog>
@vadz
vadz / frob.rnc
Created April 7, 2015 19:24
Example of RELAX NG schema for XRC with a custom element.
default namespace = "http://www.wxwidgets.org/wxxrc"
namespace xrc = "http://www.wxwidgets.org/wxxrc"
include "http://www.wxwidgets.org/wxxrc" {
customClasses =
element object {
attribute class { "Frobnicator" } &
stdObjectNodeAttributes &
stdWindowProperties &
[xrc:p="o"] element num_times {_, t_integer }*
@vadz
vadz / frob.xml
Created April 7, 2015 19:27
Fragment of an XRC file that could be validated used frob.rnc schema.
<?xml version="1.0"?>
<resource xmlns="http://www.wxwidgets.org/wxxrc" version="2.5.3.0">
<object class="Frobnicator" name="my_frob">
<num_times>17</num_times>
</object>
</resource>
#!/usr/bin/env perl6
use Term::ANSIColor;
constant @months = <January February March April May June July
August September October November December>;
my @days = <Su Mo Tu We Th Fr Sa>;
sub center(Str $text, Int $width) {
@vadz
vadz / example++98.cpp
Last active December 21, 2015 22:49
A simple wxWidgets example in C++ 98.
#include <wx/wx.h>
class MyFrame : public wxFrame
{
public:
MyFrame() : wxFrame(NULL, wxID_ANY, "Test")
{
wxSizer* sizer = new wxBoxSizer(wxHORIZONTAL);
sizer->Add(new wxStaticText(this, wxID_ANY, "Press to enlarge"), wxSizerFlags().Border().Centre());
@vadz
vadz / example++11.cpp
Last active December 21, 2015 22:59
A simple wxWidgets example converted to C++11
#include <wx/wx.h>
class MyFrame : public wxFrame
{
public:
MyFrame() : wxFrame(nullptr, wxID_ANY, "Test")
{
auto sizer = new wxBoxSizer(wxHORIZONTAL);
sizer->Add(new wxStaticText(this, wxID_ANY, "Press to enlarge"), wxSizerFlags().Border().Centre());

Random Notes About SWIG Objects Attributes

Random Notes About SWIG Objects Attributes

Overview

SWIG parses all declarations in its input in an object tree. Each node of this tree is a DOHHash and developer documentation

#include <wx/secretstore.h>
void DoSomethingRequiringAPassword(const wxString& username)
{
wxSecretStore store = wxSecretStore::GetDefault();
if ( !store.IsOk() ) {
// Complain about not being able to store the password securely
...
return;
}