mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-09-01 07:42:40 -06:00
bazaar: BoostPyTest: some new exports, like TopWindow, Log, Prompt, Progress, Callback soon to come
git-svn-id: svn://ultimatepp.org/upp/trunk@3410 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
d40392943f
commit
ba9eb36262
18 changed files with 269 additions and 3 deletions
|
|
@ -19,7 +19,8 @@ public:
|
|||
|
||||
void ExitHandler();
|
||||
|
||||
World w;
|
||||
World w;
|
||||
Progress pr;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -52,6 +52,9 @@ BoostPyTest::BoostPyTest()
|
|||
es.SetData("Hello from Upp");
|
||||
scope(upp_module).attr("es") = ptr(&es);
|
||||
|
||||
scope(upp_module).attr("pr") = ptr(&pr);
|
||||
|
||||
|
||||
//the additional import is needless
|
||||
String sc =
|
||||
|
||||
|
|
@ -70,8 +73,21 @@ BoostPyTest::BoostPyTest()
|
|||
"print upp.es.data\n"
|
||||
|
||||
"c = upp.Color(123,124,125)\n"
|
||||
"print c"
|
||||
"print c\n"
|
||||
//"upp.vc.data = c\n"
|
||||
|
||||
|
||||
"import time\n"
|
||||
"upp.pr.create()\n"
|
||||
"i = 0\n"
|
||||
"while i < 10:\n"
|
||||
" print i\n"
|
||||
" upp.pr.text = str(i)\n"
|
||||
" i = i+1\n"
|
||||
" upp.pr.step(1)\n"
|
||||
" time.sleep(1)\n"
|
||||
"upp.pr.close()\n"
|
||||
|
||||
;
|
||||
con.cmd.SetData(sc);
|
||||
|
||||
|
|
|
|||
14
bazaar/CoreBoostPy/Callback.cpp
Normal file
14
bazaar/CoreBoostPy/Callback.cpp
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#include "Callback.h"
|
||||
using namespace boost::python;
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
void export_Callback()
|
||||
{
|
||||
ONCELOCK
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
12
bazaar/CoreBoostPy/Callback.h
Normal file
12
bazaar/CoreBoostPy/Callback.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#ifndef _CoreBoostPy_Callback_h_
|
||||
#define _CoreBoostPy_Callback_h_
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
void export_Callback();
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
@ -11,6 +11,8 @@ ONCELOCK
|
|||
export_Value();
|
||||
export_ValueArray();
|
||||
export_ValueMap();
|
||||
|
||||
export_Log();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
#ifndef _CoreBoostPy_CoreBoostPy_h_
|
||||
#define _CoreBoostPy_CoreBoostPy_h_
|
||||
|
||||
#include "Misc.h"
|
||||
#include "GTypes.h"
|
||||
#include "String.h"
|
||||
#include "Value.h"
|
||||
#include "Callback.h"
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,10 @@ uses
|
|||
|
||||
file
|
||||
Common.h,
|
||||
Misc.h,
|
||||
Misc.cpp,
|
||||
Callback.h,
|
||||
Callback.cpp,
|
||||
GTypes.h,
|
||||
GTypes.cpp,
|
||||
String.h,
|
||||
|
|
|
|||
20
bazaar/CoreBoostPy/Misc.cpp
Normal file
20
bazaar/CoreBoostPy/Misc.cpp
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#include "Misc.h"
|
||||
using namespace boost::python;
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
void DoLog(const String& s)
|
||||
{
|
||||
RLOG(s);
|
||||
}
|
||||
|
||||
void export_Log()
|
||||
{
|
||||
ONCELOCK
|
||||
{
|
||||
def("log", &DoLog, "Writes to the UppLog");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
12
bazaar/CoreBoostPy/Misc.h
Normal file
12
bazaar/CoreBoostPy/Misc.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#ifndef _CoreBoostPy_Misc_h_
|
||||
#define _CoreBoostPy_Misc_h_
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
void export_Log();
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
@ -52,9 +52,15 @@ void CtrlReject(Ctrl& c) { c.Reject(); }
|
|||
void CtrlSetModify(Ctrl& c, bool b) { if (b) c.SetModify(); else c.ClearModify(); }
|
||||
bool CtrlIsModified(const Ctrl& c) { return c.IsModified(); }
|
||||
|
||||
Size CtrlGetMinSize(Ctrl& c) { return c.GetMinSize(); }
|
||||
Size CtrlGetStdSize(Ctrl& c) { return c.GetStdSize(); }
|
||||
Rect CtrlGetVoidRect(Ctrl& c) { return c.GetVoidRect(); }
|
||||
|
||||
Value CtrlGetData(const Ctrl& c) { return c.GetData(); }
|
||||
void CtrlSetData(Ctrl& c, const Value& data) { c.SetData(data); }
|
||||
|
||||
void CtrlClose(Ctrl& c) { c.Close(); }
|
||||
|
||||
//return ignorers
|
||||
void CtrlWantFocus(Ctrl& c, bool b) { c.WantFocus(b); }
|
||||
void CtrlInitFocus(Ctrl& c, bool b) { c.InitFocus(b); }
|
||||
|
|
@ -118,6 +124,13 @@ ONCELOCK
|
|||
.add_property("rect", &Ctrl::GetRect, (void (Ctrl::*)(const Rect&))&Ctrl::SetRect)
|
||||
.add_property("size", &Ctrl::GetSize)
|
||||
|
||||
.add_property("minsize", &CtrlGetMinSize)
|
||||
.add_property("stdsize", &CtrlGetStdSize)
|
||||
.add_property("voidrect", &CtrlGetVoidRect)
|
||||
|
||||
.add_property("inview", &Ctrl::InView)
|
||||
.add_property("inframe", &Ctrl::InFrame)
|
||||
|
||||
.def("leftpos", &CtrlLeftPos)
|
||||
.def("rightpos", &CtrlRightPos)
|
||||
.def("toppos", &CtrlTopPos)
|
||||
|
|
@ -141,12 +154,96 @@ ONCELOCK
|
|||
.def("action", &Ctrl::Action)
|
||||
.def("refresh", (void (Ctrl::*)(void))&Ctrl::Refresh)
|
||||
|
||||
.def("close", &CtrlClose)
|
||||
.add_property("isopen", &Ctrl::IsOpen)
|
||||
|
||||
|
||||
.add_property("backpaint", &CtrlIsBackPaint, &CtrlSetBackPaint)
|
||||
.add_property("transparent", &Ctrl::IsTransparent, &CtrlTransparent)
|
||||
.add_property("tip", &Ctrl::GetTip, &CtrlSetTip)
|
||||
|
||||
.def("__str__", &CtrlToString)
|
||||
;
|
||||
|
||||
def("showrepaint", &Ctrl::ShowRepaint, "Show Repaint process in Upp");
|
||||
}
|
||||
}
|
||||
|
||||
//virtuals
|
||||
void TopWindowClose(TopWindow& c) { c.Close(); }
|
||||
|
||||
//return ignore
|
||||
void TopWindowSetTitle(TopWindow& c, const String& s) { c.Title(s); }
|
||||
String TopWindowGetTitle(const TopWindow& c) { return c.GetTitle().ToString(); }
|
||||
|
||||
void TopWindowFullScreen(TopWindow& c, bool b) { c.FullScreen(b); }
|
||||
void TopWindowSizeable(TopWindow& c, bool b) { c.Sizeable(b); }
|
||||
void TopWindowZoomable(TopWindow& c, bool b) { c.Zoomable(b); }
|
||||
void TopWindowTopMost(TopWindow& c, bool b, bool d) { c.TopMost(b, d); }
|
||||
void TopWindowToolWindow(TopWindow& c, bool b) { c.ToolWindow(b); }
|
||||
|
||||
//enum helper, boost needs namespace
|
||||
enum TopWindowEnum
|
||||
{
|
||||
_IDOK = IDOK,
|
||||
_IDCANCEL = IDCANCEL,
|
||||
_IDABORT = IDABORT,
|
||||
_IDRETRY = IDRETRY,
|
||||
_IDIGNORE = IDIGNORE,
|
||||
_IDYES = IDYES,
|
||||
_IDNO = IDNO,
|
||||
_IDCLOSE = IDCLOSE,
|
||||
_IDHELP = IDHELP,
|
||||
_IDEXIT = IDEXIT,
|
||||
};
|
||||
|
||||
void export_TopWindow()
|
||||
{
|
||||
ONCELOCK
|
||||
{
|
||||
enum_<TopWindowEnum>("choice")
|
||||
.value("idok", _IDOK)
|
||||
.value("idcancel", _IDCANCEL)
|
||||
.value("idabort", _IDABORT)
|
||||
.value("idretry", _IDRETRY)
|
||||
.value("idignore", _IDIGNORE)
|
||||
.value("idyes", _IDYES)
|
||||
.value("idno", _IDNO)
|
||||
.value("idclose", _IDCLOSE)
|
||||
.value("idhelp", _IDHELP)
|
||||
.value("idexit", _IDEXIT)
|
||||
;
|
||||
|
||||
class_<TopWindow, bases<Ctrl>, TopWindow, boost::noncopyable>("TopWindow", "Upp TopWindow", no_init)
|
||||
.def("backup", &TopWindow::Backup)
|
||||
.def("restore", &TopWindow::Restore)
|
||||
.def("break", &TopWindow::Break)
|
||||
.def("acceptbreak", &TopWindow::AcceptBreak)
|
||||
.def("rejectbreak", &TopWindow::RejectBreak)
|
||||
|
||||
.def("workareatrim", &TopWindow::WorkAreaTrim)
|
||||
|
||||
.def("setminsize", &TopWindow::SetMinSize)
|
||||
|
||||
.def("open", (void (TopWindow::*)())&TopWindow::Open)
|
||||
.def("openmain", &TopWindow::OpenMain)
|
||||
.def("run", &TopWindow::Run)
|
||||
.def("runappmodal", &TopWindow::RunAppModal)
|
||||
.def("execute", &TopWindow::Execute)
|
||||
.def("executeok", &TopWindow::ExecuteOK)
|
||||
.def("executecancel", &TopWindow::ExecuteCancel)
|
||||
|
||||
.add_property("minimize", &TopWindow::IsMinimized, &TopWindow::Minimize)
|
||||
.add_property("maximize", &TopWindow::IsMaximized, &TopWindow::Maximize)
|
||||
.add_property("overlap", &TopWindow::IsOverlapped, &TopWindow::Overlap)
|
||||
|
||||
.add_property("sizeable", &TopWindow::IsSizeable, &TopWindowSizeable)
|
||||
.add_property("zoomable", &TopWindow::IsZoomable, &TopWindowZoomable)
|
||||
.add_property("topmost", &TopWindow::IsTopMost, &TopWindowTopMost)
|
||||
.add_property("toolwindow", &TopWindow::IsToolWindow, &TopWindowToolWindow)
|
||||
|
||||
.add_property("fullscreen", &TopWindow::IsFullScreen, &TopWindowFullScreen)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ NAMESPACE_UPP
|
|||
void export_Logc();
|
||||
void export_LogPos();
|
||||
void export_CtrlCore();
|
||||
void export_TopWindow();
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
|
|
|
|||
|
|
@ -7,10 +7,14 @@ void export_CtrlLib()
|
|||
ONCELOCK
|
||||
{
|
||||
export_CtrlCore();
|
||||
export_EditCtrl();
|
||||
export_TopWindow();
|
||||
|
||||
export_EditCtrl();
|
||||
export_SliderCtrl();
|
||||
export_ValueCtrl();
|
||||
export_Progress();
|
||||
|
||||
export_Prompts();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,9 +2,11 @@
|
|||
#define _CtrlLibBoostPy_CtrlLibBoostPy_h_
|
||||
|
||||
#include "CtrlCore.h"
|
||||
#include "Misc.h"
|
||||
#include "EditCtrl.h"
|
||||
#include "SliderCtrl.h"
|
||||
#include "ValueCtrl.h"
|
||||
#include "Progress.h"
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
|
|
|
|||
|
|
@ -7,12 +7,16 @@ file
|
|||
Common.h,
|
||||
CtrlCore.h,
|
||||
CtrlCore.cpp,
|
||||
Misc.h,
|
||||
Misc.cpp,
|
||||
SliderCtrl.h,
|
||||
SliderCtrl.cpp,
|
||||
ValueCtrl.h,
|
||||
ValueCtrl.cpp,
|
||||
EditCtrl.h,
|
||||
EditCtrl.cpp,
|
||||
Progress.h,
|
||||
Progress.cpp,
|
||||
CtrlLibBoostPy.h,
|
||||
CtrlLibBoostPy.cpp;
|
||||
|
||||
|
|
|
|||
21
bazaar/CtrlLibBoostPy/Misc.cpp
Normal file
21
bazaar/CtrlLibBoostPy/Misc.cpp
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
#include "Misc.h"
|
||||
using namespace boost::python;
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
void export_Prompts()
|
||||
{
|
||||
ONCELOCK
|
||||
{
|
||||
def("promptok", &PromptOK, "Prompts OK");
|
||||
def("promptokcancel", &PromptOKCancel, "Prompts OK/Cancel");
|
||||
def("promptabortretry", &PromptAbortRetry, "Prompts Abort/Retry");
|
||||
def("promptabortretryignore", &PromptAbortRetryIgnore, "Prompts Abort/Retry/Ignore");
|
||||
def("promptretrycancel", &PromptRetryCancel, "Prompts Retry/Cancel");
|
||||
def("promptyesno", &PromptYesNo, "Prompts Yes/No");
|
||||
def("promptyesnocancel", &PromptYesNoCancel, "Prompts Yes/No/Cancel");
|
||||
def("exclamation", &Exclamation, "Exclamates an Error Dialog");
|
||||
}
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
12
bazaar/CtrlLibBoostPy/Misc.h
Normal file
12
bazaar/CtrlLibBoostPy/Misc.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#ifndef _CtrlLibBoostPy_Misc_h_
|
||||
#define _CtrlLibBoostPy_Misc_h_
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
void export_Prompts();
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#endif
|
||||
30
bazaar/CtrlLibBoostPy/Progress.cpp
Normal file
30
bazaar/CtrlLibBoostPy/Progress.cpp
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#include "Progress.h"
|
||||
using namespace boost::python;
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
void export_Progress()
|
||||
{
|
||||
ONCELOCK
|
||||
{
|
||||
class_<Progress, bases<TopWindow>, Progress, boost::noncopyable>("Progress", "Upp Progress", no_init)
|
||||
.add_property("pos", &Progress::GetPos, &Progress::SetPos)
|
||||
.add_property("total", &Progress::GetTotal, &Progress::SetTotal)
|
||||
.add_property("text", &Progress::GetText, (void (Progress::*)(const String&))&Progress::SetText)
|
||||
|
||||
.def("create", &Progress::Create)
|
||||
.def("cancel", &Progress::Cancel)
|
||||
.def("reset", &Progress::Reset)
|
||||
.def("set", &Progress::Set)
|
||||
.def("step", &Progress::Step)
|
||||
|
||||
.def("canceled", &Progress::Canceled)
|
||||
.def("setcanceled", &Progress::SetCanceled)
|
||||
.def("setposcanceled", &Progress::SetPosCanceled)
|
||||
.def("stepcanceled", &Progress::StepCanceled)
|
||||
;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
12
bazaar/CtrlLibBoostPy/Progress.h
Normal file
12
bazaar/CtrlLibBoostPy/Progress.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#ifndef _CtrlLibBoostPy_Progress_h_
|
||||
#define _CtrlLibBoostPy_Progress_h_
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
void export_Progress();
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue