Forums

wxWidgets / wx.NET

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

Re: wxWidgets / wx.NET

Postby Charles » Mon Oct 26, 2009 1:29 am

Some GUIs require STAThread. See http://cobra-language.com/how-to/WPF/ for example. Looks like we might have missed it in WinForms. I see it in the C# code your included.

Re: C# <--> Cobra, there is a wiki page on C# that you may find useful. Also, being a wiki, feel free to edit and correct as you're learning.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: wxWidgets / wx.NET

Postby hopscc » Mon Oct 26, 2009 4:08 am

Theres still some weird ordure going on here around specifying 'wx'
( ar at least unexpected, less than desirable)...

The wrappers are defined like
// Frame.cs
using System;
using System.Drawing;
using System.Runtime.InteropServices;

namespace wx
{
public class Frame : Window
...


If you use 'wx." in class defn ( inherits) or on param types ( as wx.Event) it gens a compiler error
error: Cannot find type for "wx.Frame".

presumably due the cobra case remapping


The same prefix in code on methods ('fileMenu = wx.Menu()') compiles fine,
it also compiles fine without the 'wx' prefix ('fileMenu = Menu()') presumably cos its falling through and finding the
right (only) reference.
but fails similarly for local typenames ( ic as wx.Icon)

The failures re assigning to .icon seem to be due to Icon in the wx.NET wrapper code being a property
Code: Select all
// In Frame.cs
public Icon Icon
      {
         set { wxFrame_SetIcon(wxObject, Object.SafePtr(value)); }
      }

Theres a similar case for .setStatusText - theres a method call (SetStatusText) and a property... If you modify the cobra code to use the property
instead of the (working) method call
Code: Select all
.statusText='diddley dee'

that doesnt compile either...
Dunno what thats about

this form using STAThd compiles for me ( latest tree src)
Code: Select all
   def main has STAThread is shared
      print 'main'       

as does
Code: Select all
   def main has STAThread
      is shared
      print 'main'       

- both put
Code: Select all
[STAThreadAttribute]

In the generated cs code which is presumably the desired effect

and
What do you mean "it has its own version of 'object'"? And how does that affect C#, VB, Cobra, ...?


It affects Cobra because since it wont find/compile 'wx.Object' you cant explicitly disambiguate Object to wx.Object rather than System.Object.
If you specify a non namespaced form ( like 'Frame 'vs 'wx.Frame', i.e 'Object') cobra gives
'error: Ambiguous reference "Object" found in namespaces "System" and "wx".'

Theres a similar situation with the wx version of Icon

I'd hold off on a Wx.Net howto until we either allow cobra to work correctly/clearly with explicit wrong cased namespaces ( types in ) or
work out an intelligible description of whats happening and how to write code to accomodate it....
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand

Re: wxWidgets / wx.NET

Postby hopscc » Mon Oct 26, 2009 6:59 am

Chuck, using your previously posted example code heres the failure cases
all in lower case namespace qualified Types

Code: Select all
use little

#uncomment commented 'little.' text below in  each individual numbered line in order
# - compiles will fail

class P inherits /#little.#/A    # /1

   def main
      a = little.A()
      assert a.one == 1
      a = A()
      assert a.one == 1
      print 'done.'
   
      aa as /#little.#/A = little.A()  # /3
      assert aa.one == 1
      
   def x(a as /#little.#/A)      # /2
      assert a.one == 1
   
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand

Re: wxWidgets / wx.NET

Postby hopscc » Thu Oct 29, 2009 5:57 am

Theres a new converted wx.Net sample file (ListView.{cs, cobra}) and a new wiki page on a process for converting C# + wx.NET source to cobra at
WxWidgets Port.

Patch for having cobra compiler address issue in previous post under construction...
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand

Re: wxWidgets / wx.NET

Postby Charles » Thu Oct 29, 2009 11:52 am

Thanks.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: wxWidgets / wx.NET

Postby hopscc » Mon Nov 02, 2009 12:37 am

Patch on ticket:184.
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand

Re: wxWidgets / wx.NET

Postby Charles » Mon Nov 30, 2009 1:06 am

Patch applied. Thanks.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Previous

Return to Discussion

Who is online

Users browsing this forum: No registered users and 84 guests

cron