Skip to content
Browse files

Fix issues with Rice inheritance, add Dock and Sound API

  • Loading branch information...
1 parent 4a7a477 commit 68979660ed4e63b6d240784708138939239e337a @maccman committed Dec 17, 2009
View
2 TODO
@@ -20,4 +20,4 @@ Get copy/past keyboard shortcuts working
Allow js popup windows
Allow js alerts
-Fix error that sometimes occurs when app exits
+-Fix error that sometimes occurs when app exits
View
7 bowline/badge_label.h
@@ -0,0 +1,7 @@
+#ifndef __BADGE_LABEL_h__
+#define __BADGE_LABEL_h__
+
+extern void wxRemoveBadgeLabel();
+extern void wxSetBadgeLabel(wxString label);
+
+#endif
View
16 bowline/badge_label.mm
@@ -0,0 +1,16 @@
+#import <Cocoa/Cocoa.h>
+
+void wxSetBadgeLabel(wxString label) {
+#if wxUSE_UNICODE
+ NSString *temp = [NSString stringWithUTF8String:label.mb_str(wxConvUTF8)];
+#else
+ NSString *temp = [NSString stringWithCString:label.c_str() length:label.Len()];
+#endif
+ NSDockTile *dockTile = [[NSApplication sharedApplication] dockTile];
+ [dockTile setBadgeLabel:temp];
+}
+
+void wxRemoveBadgeLabel() {
+ NSDockTile *dockTile = [[NSApplication sharedApplication] dockTile];
+ [dockTile setBadgeLabel:nil];
+}
View
5 bowline/bowline.cpp
@@ -6,6 +6,8 @@
#include "bowline_misc.cpp"
#include "bowline_network.cpp"
#include "bowline_dialog.cpp"
+#include "bowline_sound.cpp"
+// #include "bowline_dock.cpp"
#include "bowline_main_window.cpp"
void InitBowline(){
@@ -15,7 +17,8 @@ void InitBowline(){
Init_Bowline_Misc();
Init_Bowline_Network();
Init_Bowline_Dialog();
-
+ Init_Bowline_Sound();
+ // Init_Bowline_Dock();
Init_Bowline_Control();
Init_Bowline_Window();
Init_Bowline_Main_Window();
View
73 bowline/bowline_control.cpp
@@ -8,7 +8,7 @@
#define wxWebkitBeforeLoadEventHandler(func) \
(wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxWebKitBeforeLoadEventFunction, &func)
-class BowlineControl : public wxFrame
+class BowlineControl
{
public:
BowlineControl (
@@ -17,12 +17,19 @@ class BowlineControl : public wxFrame
const wxString name = wxEmptyString,
const bool chrome = true,
const wxSize size = wxDefaultSize
- ) : wxFrame(parent, wxID_ANY, name, wxDefaultPosition, size) {
+ ) {
+ frame = new wxFrame(
+ parent,
+ wxID_ANY,
+ name,
+ wxDefaultPosition,
+ size
+ );
menuBar = new wxMenuBar;
- SetMenuBar(menuBar);
+ frame->SetMenuBar(menuBar);
- webkit = new wxWebKitCtrl(this, wxID_ANY, wxEmptyString);
+ webkit = new wxWebKitCtrl(frame, wxID_ANY, wxEmptyString);
LoadFile(path);
}
@@ -48,7 +55,7 @@ class BowlineControl : public wxFrame
default_path,
wxDD_DEFAULT_STYLE,
wxDefaultPosition,
- this
+ frame
);
return path;
}
@@ -69,20 +76,62 @@ class BowlineControl : public wxFrame
default_extension,
wildcard,
flags,
- this
+ frame
);
return path;
}
- void SetHeight(int height){
- // TODO
+ void Center(){
+ // TODO - Support direction
+ frame->Center();
}
- void SetWidth(int width){
- // TODO
+ void Close(){
+ frame->Close(false);
+ }
+
+ void Show(){
+ frame->Show(true);
+ }
+
+ void Hide(){
+ frame->Show(false);
+ }
+
+ void Enable(){
+ frame->Enable(true);
+ }
+
+ void Disable(){
+ frame->Enable(false);
+ }
+
+ int GetId() const{
+ return frame->GetId();
+ }
+
+ void MakeModal(bool flag){
+ frame->MakeModal(flag);
+ }
+
+ void SetName(wxString name){
+ frame->SetName(name);
+ }
+
+ void Raise(){
+ frame->Raise();
+ }
+
+ void SetSize(int height, int width){
+ frame->SetSize(-1, -1, height, width, wxSIZE_USE_EXISTING);
+ }
+
+ void SetPosition(int x, int y){
+ frame->Move(x, y);
}
protected:
+ wxFrame* frame;
wxWebKitCtrl* webkit;
wxMenuBar *menuBar;
};
@@ -102,8 +151,8 @@ void Init_Bowline_Control(){
.define_method("run_script", &BowlineControl::RunScript)
.define_method("raise", &BowlineControl::Raise)
.define_method("show", &BowlineControl::Show, Arg("show") = true)
- .define_method("height=", &BowlineControl::SetHeight)
- .define_method("width=", &BowlineControl::SetWidth)
+ .define_method("set_size", &BowlineControl::SetSize)
+ .define_method("set_position",&BowlineControl::SetPosition)
.define_method("select_dir", &BowlineControl::SelectDir,
(
Arg("message") = (wxString)"Choose a directory",
View
28 bowline/bowline_dock.cpp
@@ -0,0 +1,28 @@
+#include "bowline.h"
+#ifdef __WXMAC__
+#include "badge_label.h"
+#endif
+
+using namespace Rice;
+
+void bowline_dock_set_badge(wxString val){
+ #ifdef __WXMAC__
+ wxSetBadgeLabel(val);
+ #endif
+}
+
+void bowline_dock_clear_badge(){
+ #ifdef __WXMAC__
+ wxRemoveBadgeLabel();
+ #endif
+}
+
+void Init_Bowline_Dock(){
+ Module rb_mBowline = define_module("Bowline");
+ Module rb_mBowlineDesktop = define_module_under(rb_mBowline, "Desktop");
+
+ Class rb_cBowlineDock =
+ define_class_under(rb_mBowlineDesktop, "Dock")
+ .define_singleton_method("badge=", &bowline_dock_set_badge)
+ .define_singleton_method("clear_badge", &bowline_dock_clear_badge);
+}
View
14 bowline/bowline_main_window.cpp
@@ -20,33 +20,31 @@ class BowlineMainWindow : public BowlineControl
) : BowlineControl(NULL, path, name, chrome, size)
{
BowlineMainWindow::SetInstance(this);
- wxTheApp->SetTopWindow(this);
+ wxTheApp->SetTopWindow(frame);
fileMenu = new wxMenu();
fileMenu->Append(ID_Quit, _("E&xit"));
menuBar->Append(fileMenu, _("&File"));
- Connect( ID_Quit, wxEVT_COMMAND_MENU_SELECTED,
+ frame->Connect( ID_Quit, wxEVT_COMMAND_MENU_SELECTED,
(wxObjectEventFunction) &BowlineMainWindow::OnQuit );
};
void SetupConfiguration(){
- wxSize coords = wxSize(
- BowlineConfig::getInt(_("width")),
- BowlineConfig::getInt(_("height"))
- );
wxString appName = BowlineConfig::getString(_("name"));
bool chrome = BowlineConfig::getBool(_("chrome"));
wxString path = BowlineConfig::getString(_("index_path"));
+ int width = BowlineConfig::getInt(_("width"));
+ int height = BowlineConfig::getInt(_("height"));
SetName(appName);
- SetSize(coords);
+ SetSize(height, width);
SetChrome(chrome);
LoadFile(path);
}
void OnQuit(wxCommandEvent& WXUNUSED(event))
{
- Close(true);
+ Close();
}
static BowlineMainWindow *GetInstance(){ return mainWindowInstance; }
View
17 bowline/bowline_sound.cpp
@@ -0,0 +1,17 @@
+#include "bowline.h"
+#include <wx/sound.h>
+
+using namespace Rice;
+
+void bowline_sound_play(wxString path){
+ wxSound(path).Play();
+}
+
+void Init_Bowline_Sound(){
+ Module rb_mBowline = define_module("Bowline");
+ Module rb_mBowlineDesktop = define_module_under(rb_mBowline, "Desktop");
+
+ Class rb_cBowlineSound =
+ define_class_under(rb_mBowlineDesktop, "Sound")
+ .define_singleton_method("play", &bowline_sound_play);
+}
View
17 bowline/bowline_window.cpp
@@ -11,12 +11,7 @@ using namespace Rice;
class BowlineWindow : public BowlineControl
{
public:
- BowlineWindow (
- const wxString path = wxEmptyString,
- const wxString name = wxEmptyString,
- const bool chrome = true,
- const wxSize size = wxDefaultSize
- ) : BowlineControl(wxTheApp->GetTopWindow(), path, name, chrome, size) {
+ BowlineWindow() : BowlineControl(wxTheApp->GetTopWindow()) {
}
};
@@ -33,17 +28,9 @@ void Init_Bowline_Window(){
Module rb_mBowline = define_module("Bowline");
Module rb_mBowlineDesktop = define_module_under(rb_mBowline, "Desktop");
- // TODO - default arguments for the constructor
- // (
- // Arg("path") = wxEmptyString,
- // Arg("name") = wxEmptyString,
- // Arg("chrome") = true,
- // Arg("size") = wxDefaultSize
- // )
-
Class rb_cBowlineWindow =
define_class_under<BowlineWindow, BowlineControl>(rb_mBowlineDesktop, "Window")
- .define_constructor(Constructor<BowlineWindow, wxString, wxString, bool, wxSize>());
+ .define_constructor(Constructor<BowlineWindow>());
}
#endif /* end of include guard: BOWLINE_WINDOW_CPP_PU66Y890 */
View
2 main.cpp
@@ -51,7 +51,7 @@ bool App::OnInit()
tickTimer.Start(50);
window->SetupConfiguration();
- window->Show(true);
+ window->Show();
#ifdef __WXMAC__
// Enable interaction for unbundled apps
View
1 ruby_gvl.cpp
@@ -1,4 +1,3 @@
-#include "ruby_gvl.h"
struct rb_blocking_region_buffer *RubyGVL::curb_lock = NULL;
bool RubyGVL::locked = true;

0 comments on commit 6897966

Please sign in to comment.
Something went wrong with that request. Please try again.