Skip to content

Commit

Permalink
fixes for glcanvas
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbb committed Mar 2, 2016
1 parent baf6a14 commit 3eb6e4c
Show file tree
Hide file tree
Showing 27 changed files with 257 additions and 38 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

std.locale.global(std.locale(""))
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

void MyFrame.SomeFunction()

try
MyDialog dlg(self)
dlg.ShowModal()
catch (const MyExpectedException& e)
# Deal with the exceptions thrown from the dialog.

Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

class MyApp : public wx.App
public:
virtual bool StoreCurrentException()

try
throw
catch (const std.runtime_exception& e)
if (!self.runtimeError.empty())
# This is not supposed to happen, only one exception,
# at most, should be stored.
return false


self.runtimeError = e.what()

# Don't terminate, let our code handle self exception later.
return true
catch (...)
# This could be extended to store information about any
# other exceptions too, but if we don't store them, we
# should return false to let the program die.


return false


virtual void RethrowStoredException()

if (!self.runtimeError.empty())
std.runtime_exception e(self.runtimeError)
self.runtimeError.clear()
throw e



private:
std.string self.runtimeError
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

#include <wx./imagpng.h>
10 changes: 10 additions & 0 deletions docs/sphinx/rest_substitutions/snippets/python/BusyInfo.3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

wx.WindowDisabler disableAll
wx.BusyInfo wait("Please wait, working...")

for (int i = 0 i < 100000 i++)

DoACalculation()

if (!(i % 1000))
wx.TheApp.Yield()
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

wx.BusyInfo(wx.BusyInfoFlags().Parent(parent).Label(message))
11 changes: 11 additions & 0 deletions docs/sphinx/rest_substitutions/snippets/python/BusyInfoFlags.1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

wx.BusyInfo info
(
wx.BusyInfoFlags()
.Parent(window)
.Icon(icon)
.Title("Some text")
.Text("Some more text")
.Foreground(wx.Colour(...))
.Background(wx.Colour(...))
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

(time_t)-1
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

class MyClass : public BaseClass # inheriting from wx.EvtHandler

...
protected:
virtual bool TryAfter(wx.Event& event)

if (BaseClass.TryAfter(event))
return true

return MyPostProcess(event)

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

class MyClass : public BaseClass # inheriting from wx.EvtHandler

...
protected:
virtual bool TryBefore(wx.Event& event)

if (MyPreProcess(event))
return true

return BaseClass.TryBefore(event)

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

wx.Image image
image.SetLoadFlags(image.GetLoadFlags() & ~wx.Image.Load_Verbose)
image.LoadFile(...)
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

mySVGFileDC.SetBitmapHandler(wx.SVGBitmapEmbedHandler())
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

wx.Bitmap bmp(FromDIP(32, 32))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

wx.Bitmap bmp(FromDIP(32, 32))
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

wx.Point pt(ToDIP(GetPosition()))
wx.Size size(ToDIP(GetSize()))
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

wx.Point pt(ToDIP(GetPosition()))
wx.Size size(ToDIP(GetSize()))
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

wx.GLContextAttrs cxtAttrs
# Some values
cxtAttrs.CoreProfile().OGLVersion(5, 0) # OGL 5.0, whenever available
cxtAttrs.PlatformDefaults()
# Values usually are platform-dependant named (even value assigned!)
#if defined(__WXMSW__)
cxtAttrs.AddAttribute(WGL_NEW_CTX_F)
cxtAttrs.AddAttribBits(WGL_CONTEXT_PROFILE_MASK_ARB, WGL_NEW_BITS)
#elif defined(__WXX11__)
cxtAttrs.AddAttribute(GLX_NEW_CTX_F)
cxtAttrs.AddAttribBits(GLX_CONTEXT_PROFILE_MASK_ARB, GLX_NEW_BITS)
#else
# Other platforms
#endif
cxtAttrs.EndList() # Don't forget self
cxtAttrs.SetNeedsARB(true) # Context attributes are set by an ARB-function
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

wx.GLAttributes dispAttrs
dispAttrs.PlatformDefaults().MinRGBA(8, 8, 8, 8).DoubleBuffer().Depth(32).EndList()
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

wx.GLContextAttrs cxtAttrs
cxtAttrs.CoreProfile().OGLVersion(4, 5).Robust().ResetIsolation().EndList()
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

TAG_HANDLER_BEGIN(MYITEM, "MYITEMS")
TAG_HANDLER_PROC(tag)

# ...something...

self.Parser . PushTagHandler(self, "PARAM")
ParseInner(tag)
self.Parser . PopTagHandler()

# ...something...

TAG_HANDLER_END(MYITEM)
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

text/html
text/plain
image/*
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

#include <webkit/webkit.h>

#ifdef __WXGTK__
WebKitWebView*
wv = static_cast<WebKitWebView*>(self.window.GetNativeBackend())

WebKitWebSettings* settings = webkit_web_view_get_settings(wv)
g_object_set(G_OBJECT(settings),
"enable-frame-flattening", TRUE,
NULL)
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

#connect to the media event
self.Connect(wx.MY_ID, wx.EVT_MEDIA_STOP, (wx.ObjectEventFunction)
(wx.EventFunction)(wx.MediaEventFunction) &MyFrame.OnMediaStop)

#...
void MyFrame.OnMediaStop(const wx.MediaEvent& evt)

if(bUserWantsToSeek)

self.mediactrl.SetPosition(
self.mediactrl.GetDuration() << 1
)
evt.Veto()

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

# Create a document and add the root node.
wx.XmlDocument xmlDoc

wx.XmlNode* root = wx.XmlNode(NULL, wx.XML_ELEMENT_NODE, "Root")
xmlDoc.SetRoot(root)

# Add some XML.
wx.XmlNode* library = wx.XmlNode (root, wx.XML_ELEMENT_NODE, "Library")
library.AddAttribute("type", "CrossPlatformList")
wx.XmlNode* name = wx.XmlNode(library, wx.XML_ELEMENT_NODE, "Name")
name.AddChild(wx.XmlNode(wx.XML_TEXT_NODE, "", "wx.Widgets"))

# Write the output to a wx.String.
wx.StringOutputStream stream
xmlDoc.Save(stream)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

<?xml version="1.0" encoding="UTF-8"?>
<Root>
<Library type="CrossPlatformList">
<Name>wx.Widgets</Name>
</Library>
</Root>
53 changes: 26 additions & 27 deletions etg/_glcanvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,33 +74,32 @@ def run():

# We already have a MappedType for wxArrayInt, so just tweak the
# interfaces to use that instead of a const int pointer.
# c.find('wxGLCanvas').ignore()

# m = c.addCppCtor_sip(
# argsString="""(
# wxWindow* parent, wxWindowID id=wxID_ANY, wxArrayInt* attribList=NULL,
# const wxPoint& pos=wxDefaultPosition, const wxSize& size=wxDefaultSize,
# long style=0, const wxString& name="GLCanvas",
# const wxPalette& palette=wxNullPalette)""",
# cppSignature="""(
# wxWindow* parent, wxWindowID id=wxID_ANY, const int* attribList=NULL,
# const wxPoint& pos=wxDefaultPosition, const wxSize& size=wxDefaultSize,
# long style=0, const wxString& name="GLCanvas",
# const wxPalette& palette=wxNullPalette)""",
# pyArgsString="(self, parent, id=ID_ANY, attribList=None, pos=DefaultPosition, size=DefaultSize, style=0, name='GLCanvas', palette=NullPalette)",
# body="""\
# const int* attribPtr = NULL;
# if (attribList)
# attribPtr = &attribList->front();
# sipCpp = new sipwxGLCanvas(parent, id, attribPtr, *pos, *size, style, *name, *palette);
# """,
# noDerivedCtor=False,
# )




m = c.find('IsDisplaySupported')
for overload in c.find('wxGLCanvas').overloads:
overload.ignore()

m = c.addCppCtor_sip(
argsString="""(
wxWindow* parent, wxWindowID id=wxID_ANY, wxArrayInt* attribList=NULL,
const wxPoint& pos=wxDefaultPosition, const wxSize& size=wxDefaultSize,
long style=0, const wxString& name="GLCanvas",
const wxPalette& palette=wxNullPalette)""",
cppSignature="""(
wxWindow* parent, wxWindowID id=wxID_ANY, const int* attribList=NULL,
const wxPoint& pos=wxDefaultPosition, const wxSize& size=wxDefaultSize,
long style=0, const wxString& name="GLCanvas",
const wxPalette& palette=wxNullPalette)""",
pyArgsString="(self, parent, id=ID_ANY, attribList=None, pos=DefaultPosition, size=DefaultSize, style=0, name='GLCanvas', palette=NullPalette)",
body="""\
const int* attribPtr = NULL;
if (attribList)
attribPtr = &attribList->front();
sipCpp = new sipwxGLCanvas(parent, id, attribPtr, *pos, *size, style, *name, *palette);
""",
noDerivedCtor=False)

module.find('wxGLAttribsBase').find('GetGLAttrs').ignore()

m = c.find('IsDisplaySupported').findOverload('(const int *attribList)')
m.find('attribList').type = 'wxArrayInt*'
m.setCppCode_sip("""\
const int* attribPtr = NULL;
Expand Down
36 changes: 25 additions & 11 deletions etg/notifmsg.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,51 @@
import etgtools
import etgtools.tweaker_tools as tools

PACKAGE = "wx"
PACKAGE = "wx"
MODULE = "_adv"
NAME = "notifmsg" # Base name of the file to generate to for this script
DOCSTRING = ""

# The classes and/or the basename of the Doxygen XML files to be processed by
# this script.
# this script.
ITEMS = [ "wxNotificationMessage",
]
]

#---------------------------------------------------------------------------

def run():
# Parse the XML file(s) building a collection of Extractor objects
module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING)
etgtools.parseDoxyXML(module, ITEMS)

#-----------------------------------------------------------------
# Tweak the parsed meta objects in the module object as needed for
# customizing the generated code and docstrings.

c = module.find('wxNotificationMessage')
assert isinstance(c, etgtools.ClassDef)



c.find('MSWUseToasts').setCppCode("""\
#ifdef __WXMSW__
return self->MSWUseToasts(*shorcutPath, *appId);
#else
return false;
#endif
""")

c.find('UseTaskBarIcon').setCppCode("""\
#ifdef __WXMSW__
return self->UseTaskBarIcon(icon*);
#else
return NULL;
#endif
""")

#-----------------------------------------------------------------
tools.doCommonTweaks(module)
tools.runGenerators(module)


#---------------------------------------------------------------------------
if __name__ == '__main__':
run()

0 comments on commit 3eb6e4c

Please sign in to comment.