List Info

Thread: MiniFrame.i




MiniFrame.i
user name
2006-07-24 22:46:11
Hi

Another little patch, adding MiniFrame (a frame with small
title bar and 
buttons which doesn't appear in the desktop taskbar).

Also a sample - not very interesting, happy to roll this
into something 
else if that's better.

cheers
alex
#   Copyright 2004-2005 by Kevin Smith
#   released under the MIT-style wxruby2 license

%include "../common.i"

%module(directors="1") wxMiniFrame

%{
#include <wx/minifram.h>
%}

%import "include/wxObject.h"
%import "include/wxEvtHandler.h"
%import "include/wxWindow.h"
%import "include/wxFrame.h"


%include "include/wxMiniFrame.h"
require 'wx'

class MyFrame < Wx::Frame
  def initialize(title, pos, size, style = Wx:EFAULT_F
RAME_STYLE)
    super(nil, -1, title, pos, size, style)


    menuFile = Wx::Menu.new()
    helpMenu = Wx::Menu.new()
    helpMenu.append(Wx::ID_ABOUT,
"&About...\tF1", "Show about
dialog")
    menuFile.append(Wx::ID_EXIT,
"E&xit\tAlt-X", "Quit this
program")
    menuBar = Wx::MenuBar.new()
    menuBar.append(menuFile, "&File")
    menuBar.append(helpMenu, "&Help")
    set_menu_bar(menuBar)

    create_status_bar(2)
    set_status_text("Welcome to wxRuby!")

    evt_menu(Wx::ID_EXIT) 
    evt_menu(Wx::ID_ABOUT) 
    m = Wx::MiniFrame.new(nil, -1, 'Mini Frame')
    m.show()

  end

  def onQuit
    close(Wx::TRUE)
  end

  def onAbout
    msg =  sprintf("This is the About dialog of the
miniframe sample.\n" \
                    "Welcome to %s",
VERSION_STRING)

    message_box(msg, "About MiniFrame", OK |
ICON_INFORMATION, self)
    
  end
end

class RbApp < Wx::App
  def on_init
    frame = MyFrame.new("Mini Frame wxRuby App",
                        Wx::Point.new(50, 50), 
                        Wx::Size.new(450, 340))

    frame.show(TRUE)

  end
end

app = RbApp.new
app.main_loop()

_______________________________________________
wxruby-users mailing list
wxruby-usersrubyforge.org
ht
tp://rubyforge.org/mailman/listinfo/wxruby-users
MiniFrame.i
user name
2006-07-25 06:00:06
That code compiled nice for me on OS X and worked fine. The
only
problem I see is that VERSION_STRING is not defined.

wxWidgets 2.6.3
swig 1.3.29
iMac Intel OS X 10.4.7

Sean

On 7/24/06, Alex Fenton <alexpressure.to> wrote:
> Hi
>
> Another little patch, adding MiniFrame (a frame with
small title bar and
> buttons which doesn't appear in the desktop taskbar).
>
> Also a sample - not very interesting, happy to roll
this into something
> else if that's better.
>
> cheers
> alex
>
>
> #   Copyright 2004-2005 by Kevin Smith
> #   released under the MIT-style wxruby2 license
>
> %include "../common.i"
>
> %module(directors="1") wxMiniFrame
>
> %{
> #include <wx/minifram.h>
> %}
>
> %import "include/wxObject.h"
> %import "include/wxEvtHandler.h"
> %import "include/wxWindow.h"
> %import "include/wxFrame.h"
>
>
> %include "include/wxMiniFrame.h"
>
> require 'wx'
>
> class MyFrame < Wx::Frame
>   def initialize(title, pos, size, style = Wx:EFAULT_F
RAME_STYLE)
>     super(nil, -1, title, pos, size, style)
>
>
>     menuFile = Wx::Menu.new()
>     helpMenu = Wx::Menu.new()
>     helpMenu.append(Wx::ID_ABOUT,
"&About...\tF1", "Show about
dialog")
>     menuFile.append(Wx::ID_EXIT,
"E&xit\tAlt-X", "Quit this
program")
>     menuBar = Wx::MenuBar.new()
>     menuBar.append(menuFile, "&File")
>     menuBar.append(helpMenu, "&Help")
>     set_menu_bar(menuBar)
>
>     create_status_bar(2)
>     set_status_text("Welcome to wxRuby!")
>
>     evt_menu(Wx::ID_EXIT) 
>     evt_menu(Wx::ID_ABOUT) 
>     m = Wx::MiniFrame.new(nil, -1, 'Mini Frame')
>     m.show()
>
>   end
>
>   def onQuit
>     close(Wx::TRUE)
>   end
>
>   def onAbout
>     msg =  sprintf("This is the About dialog of
the miniframe sample.\n" \
>                     "Welcome to %s",
VERSION_STRING)
>
>     message_box(msg, "About MiniFrame", OK
| ICON_INFORMATION, self)
>
>   end
> end
>
> class RbApp < Wx::App
>   def on_init
>     frame = MyFrame.new("Mini Frame wxRuby
App",
>                         Wx::Point.new(50, 50),
>                         Wx::Size.new(450, 340))
>
>     frame.show(TRUE)
>
>   end
> end
>
> app = RbApp.new
> app.main_loop()
>
>
> _______________________________________________
> wxruby-users mailing list
> wxruby-usersrubyforge.org
> ht
tp://rubyforge.org/mailman/listinfo/wxruby-users
>
>
_______________________________________________
wxruby-users mailing list
wxruby-usersrubyforge.org
ht
tp://rubyforge.org/mailman/listinfo/wxruby-users
MiniFrame.i
user name
2006-07-25 06:43:47
Sean Long wrote:
> That code compiled nice for me on OS X and worked fine.
The only
> problem I see is that VERSION_STRING is not defined.
>   
Oops, thanks, revised sample attached.
> wxWidgets 2.6.3
> swig 1.3.29
> iMac Intel OS X 10.4.7
>   
So it is possible to compile wxruby2 on 10.4 - just checking
b/c there's 
a bug filed against it.

http://rubyforge.org
/tracker/index.php?func=detail&aid=4633&group_id=35&
amp;atid=218

But  it looks there like the submitter was using an old 2.5
release of wx.

cheers
alex
> Sean
>
> On 7/24/06, Alex Fenton <alexpressure.to> wrote:
>   
>> Hi
>>
>> Another little patch, adding MiniFrame (a frame
with small title bar and
>> buttons which doesn't appear in the desktop
taskbar).
>>
>> Also a sample - not very interesting, happy to roll
this into something
>> else if that's better.
>>
>> cheers
>> alex
>>
>>
>> #   Copyright 2004-2005 by Kevin Smith
>> #   released under the MIT-style wxruby2 license
>>
>> %include "../common.i"
>>
>> %module(directors="1") wxMiniFrame
>>
>> %{
>> #include <wx/minifram.h>
>> %}
>>
>> %import "include/wxObject.h"
>> %import "include/wxEvtHandler.h"
>> %import "include/wxWindow.h"
>> %import "include/wxFrame.h"
>>
>>
>> %include "include/wxMiniFrame.h"
>>
>> require 'wx'
>>
>> class MyFrame < Wx::Frame
>>   def initialize(title, pos, size, style = Wx:EFAULT_F
RAME_STYLE)
>>     super(nil, -1, title, pos, size, style)
>>
>>
>>     menuFile = Wx::Menu.new()
>>     helpMenu = Wx::Menu.new()
>>     helpMenu.append(Wx::ID_ABOUT,
"&About...\tF1", "Show about
dialog")
>>     menuFile.append(Wx::ID_EXIT,
"E&xit\tAlt-X", "Quit this
program")
>>     menuBar = Wx::MenuBar.new()
>>     menuBar.append(menuFile,
"&File")
>>     menuBar.append(helpMenu,
"&Help")
>>     set_menu_bar(menuBar)
>>
>>     create_status_bar(2)
>>     set_status_text("Welcome to
wxRuby!")
>>
>>     evt_menu(Wx::ID_EXIT) 
>>     evt_menu(Wx::ID_ABOUT) 
>>     m = Wx::MiniFrame.new(nil, -1, 'Mini Frame')
>>     m.show()
>>
>>   end
>>
>>   def onQuit
>>     close(Wx::TRUE)
>>   end
>>
>>   def onAbout
>>     msg =  sprintf("This is the About dialog
of the miniframe sample.\n" \
>>                     "Welcome to %s",
VERSION_STRING)
>>
>>     message_box(msg, "About MiniFrame",
OK | ICON_INFORMATION, self)
>>
>>   end
>> end
>>
>> class RbApp < Wx::App
>>   def on_init
>>     frame = MyFrame.new("Mini Frame wxRuby
App",
>>                         Wx::Point.new(50, 50),
>>                         Wx::Size.new(450, 340))
>>
>>     frame.show(TRUE)
>>
>>   end
>> end
>>
>> app = RbApp.new
>> app.main_loop()
>>
>>
>> _______________________________________________
>> wxruby-users mailing list
>> wxruby-usersrubyforge.org
>> ht
tp://rubyforge.org/mailman/listinfo/wxruby-users
>>
>>
>>     
> _______________________________________________
> wxruby-users mailing list
> wxruby-usersrubyforge.org
> ht
tp://rubyforge.org/mailman/listinfo/wxruby-users
>
>
>   

require 'wx'

class MyFrame < Wx::Frame
  def initialize(title, pos, size, style = Wx:EFAULT_F
RAME_STYLE)
    super(nil, -1, title, pos, size, style)


    menuFile = Wx::Menu.new()
    helpMenu = Wx::Menu.new()
    helpMenu.append(Wx::ID_ABOUT,
"&About...\tF1", "Show about
dialog")
    menuFile.append(Wx::ID_EXIT,
"E&xit\tAlt-X", "Quit this
program")
    menuBar = Wx::MenuBar.new()
    menuBar.append(menuFile, "&File")
    menuBar.append(helpMenu, "&Help")
    set_menu_bar(menuBar)

    create_status_bar(2)
    set_status_text("Welcome to wxRuby!")

    evt_menu(Wx::ID_EXIT) 
    evt_menu(Wx::ID_ABOUT) 
    m = Wx::MiniFrame.new(nil, -1, 'Mini Frame')
    m.show()

  end

  def onQuit
    close(Wx::TRUE)
  end

  def onAbout
    msg =  sprintf("This is the About dialog of the
miniframe sample.\n" \
                    "Welcome to %s",
Wx::VERSION_STRING)
    message_box(msg, "About MiniFrame",
Wx::OK|Wx::ICON_INFORMATION, self)
    
  end
end

class RbApp < Wx::App
  def on_init
    frame = MyFrame.new("Mini Frame wxRuby App",
                        Wx::Point.new(50, 50), 
                        Wx::Size.new(450, 340))

    frame.show(TRUE)

  end
end

app = RbApp.new
app.main_loop()

_______________________________________________
wxruby-users mailing list
wxruby-usersrubyforge.org
ht
tp://rubyforge.org/mailman/listinfo/wxruby-users
MiniFrame.i
user name
2006-07-25 06:49:31
> So it is possible to compile wxruby2 on 10.4 - just
checking b/c there's
> a bug filed against it.
>
> http://rubyforge.org
/tracker/index.php?func=detail&aid=4633&group_id=35&
amp;atid=218
>
> But  it looks there like the submitter was using an old
2.5 release of wx.

I have had no troubles compiling on 10.4, with ppc or intel.
Well I
did have a problem once when I forgot to update to 2.6.3 and
tried
compiling with 2.6.2. I think the version of wx used and the
version
of Swig are the two biggest potential problem areas.

Sean
_______________________________________________
wxruby-users mailing list
wxruby-usersrubyforge.org
ht
tp://rubyforge.org/mailman/listinfo/wxruby-users
MiniFrame.i
user name
2006-08-13 13:40:13
On Tue, 2006-07-25 at 07:43 +0100, Alex Fenton wrote:
> >> Another little patch, adding MiniFrame (a
frame with small title bar and
> >> buttons which doesn't appear in the desktop
taskbar).
> >>
> >> Also a sample - not very interesting, happy to
roll this into something
> >> else if that's better.
> >   
> Oops, thanks, revised sample attached.

I applied this, after changing the sample About Box to use
Wx::message_box instead of just message_box, because the
latter crashed
for me.

I'm not really happy with the sample. First, the miniframe
comes up
behind the main window for me, so I didn't even notice it
at first.
Second, and more importantly, there is no clean way to exit.
Choosing
File/Exit aborts with an error, and hitting the X close box
on the main
frame leaves the miniframe active, with no way to close it.

I put the sample in etc/ and would really appreciate if you
could submit
a patch to improve it.

Thanks,

Kevin


_______________________________________________
wxruby-users mailing list
wxruby-usersrubyforge.org
ht
tp://rubyforge.org/mailman/listinfo/wxruby-users
MiniFrame.i
user name
2006-08-16 00:29:49
Hi
> I'm not really happy with the sample. First, the
miniframe comes up
> behind the main window for me, so I didn't even notice
it at first.
>   
I've modified the sample so it should raise the MiniFrame
above the main 
frame, and on OS X (for real) and Windows (according to the
docs) keep 
it above there - I think this is a common option.
> Second, and more importantly, there is no clean way to
exit. Choosing
> File/Exit aborts with an error, and hitting the X close
box on the main
> frame leaves the miniframe active, with no way to close
it.
>   
OK, have fixed the on_quit method. On OS X the miniframe is 
automatically closed when the main app window is closed, but
I've added 
an explicit call to close the miniframe call in the method.
Hopefully 
this should fix things on other platforms.

cheers
alex
Index: wxruby2/samples/etc/miniframe.rb
============================================================
=======
RCS file: /var/cvs/wxruby/wxruby2/samples/etc/miniframe.rb,v
retrieving revision 1.1
diff -b -u -r1.1 miniframe.rb
--- wxruby2/samples/etc/miniframe.rb	13 Aug 2006 13:34:51
-0000	1.1
+++ wxruby2/samples/etc/miniframe.rb	16 Aug 2006 00:26:41
-0000
 -1,6
+1,8 
 require 'wx'
 
 class MyFrame < Wx::Frame
+  attr_reader :mini
+
   def initialize(title, pos, size, style = Wx:EFAULT_F
RAME_STYLE)
     super(nil, -1, title, pos, size, style)
 
 -17,22
+19,41 
     create_status_bar(2)
     set_status_text("Welcome to wxRuby!")
 
-    evt_menu(Wx::ID_EXIT) 
-    evt_menu(Wx::ID_ABOUT) 
-    m = Wx::MiniFrame.new(nil, -1, 'Mini Frame')
-    m.show()
+    evt_menu(Wx::ID_EXIT) 
+    evt_menu(Wx::ID_ABOUT) 
+
+    make_miniframe()
+  end
 
+  def make_miniframe
+    mini = Wx::MiniFrame.new(self, -1, 'Mini Frame', 
+                              Wx::Point.new(300, 75),
Wx::Size.new(300, 150),
+                              Wx:EFAULT_F
RAME_STYLE|Wx::STAY_ON_TOP)
+    sizer = Wx::BoxSizer.new(Wx::VERTICAL)
+    text = Wx::StaticText.new(mini, -1, 'This is a
MiniFrame.')
+    sizer.add(text, 0, Wx::ALL, 2)
+    text = Wx::StaticText.new(mini, -1, 'It has a small
title bar so it')
+    sizer.add(text, 0, Wx::ALL, 2)
+    text = Wx::StaticText.new(mini, -1, 'doesn\'t take
up too much space.')
+    sizer.add(text, 0, Wx::ALL, 2)
+    text = Wx::StaticText.new(mini, -1, 'This MiniFrame
has been set to')
+    sizer.add(text, 0, Wx::ALL, 2)
+    text = Wx::StaticText.new(mini, -1, 'stay above the
main app window.')
+    sizer.add(text, 0, Wx::ALL, 2)
+    mini.set_sizer(sizer)
+    mini.show()
+    mini.raise()
   end
 
-  def onQuit
-    close(Wx::TRUE)
+  def on_quit
+    mini.close()
+    close()
   end
 
-  def onAbout
+  def on_about
     msg =  sprintf("This is the About dialog of the
miniframe sample.\n" \
                     "Welcome to %s",
Wx::VERSION_STRING)
     Wx::message_box(msg, "About MiniFrame",
Wx::OK|Wx::ICON_INFORMATION, self)
-    
   end
 end
 
 -41,9
+62,7 
     frame = MyFrame.new("Mini Frame wxRuby
App",
                         Wx::Point.new(50, 50), 
                         Wx::Size.new(450, 340))
-
-    frame.show(TRUE)
-
+    frame.show()
   end
 end
 
_______________________________________________
wxruby-users mailing list
wxruby-usersrubyforge.org
ht
tp://rubyforge.org/mailman/listinfo/wxruby-users
MiniFrame.i
user name
2006-08-17 23:39:12
On Wed, 2006-08-16 at 01:29 +0100, Alex Fenton wrote:
> I've modified the sample so it should raise the
MiniFrame above the main 
> frame, and on OS X (for real) and Windows (according to
the docs) keep 
> it above there - I think this is a common option.

Works great on Linux.

> OK, have fixed the on_quit method. On OS X the
miniframe is 
> automatically closed when the main app window is
closed, but I've added 
> an explicit call to close the miniframe call in the
method. Hopefully 
> this should fix things on other platforms.

Perfect. Thanks!

Kevin


_______________________________________________
wxruby-users mailing list
wxruby-usersrubyforge.org
ht
tp://rubyforge.org/mailman/listinfo/wxruby-users
[1-7]

about | contact  Other archives ( Real Estate discussion Medical topics )