This application should be the entry point of TWEAPPS creation. A single button, displaying a simple message.
Of course all of this is written using TeapotWare, which makes the code virtually cross-plateform.
#ifndef _TWA_HELLO_WORLD_ #define _TWA_HELLO_WORLD_ #include <twmodule/twappletmod.h> #include <twui/twuiwindow.h> #include <twui/twuibutton.h> class TWHelloWorldApplet : public TWAppletMod, public TWIUIEventHandler { private: TWUIButton m_okbtn; TWUIWindow * m_window; protected: void OnCommand(TWUIItem *p_item); TWBOOL Init(TWUIWindow * p_target, TWIWebBrowser *p_browser, TWPropertyBag *p_params); void Release() {}; TWBOOL Main(); public: TWHelloWorldApplet(); }; DECL_TWMODULE(TWHelloWorldApplet); #endif
#include "twahelloworld.h" #include <twui/twuihelper.h> #include <twsystem/twshell.h> TWBOOL TWHelloWorldApplet::Init(TWUIWindow * p_target, TWIWebBrowser *p_browser, TWPropertyBag *p_params) { TWString str; p_params->GetProperty("@temp_path",str); //@temp_path is the temporary path created by the web browser, containing the files extracted from the TWA TWShell::Cd(str); //useless here, but it can be usefull in other tweapps (to seek for resource) TWUIHelper::LoadUIManager("twuimanagerw32.twm"); m_okbtn.SetText("Click Me!"); m_okbtn.SetPosition(30,30); m_okbtn.SetSize(100,30); m_okbtn.SetParent(p_target); m_okbtn.Init(); m_okbtn.SetEventHandler(this); p_target->SetEventHandler(this); m_window=p_target; return TRUE; } void TWHelloWorldApplet::OnCommand(TWUIItem *p_item) { if(p_item==&m_okbtn) { TWUIHelper::MsgBox("Hello World!\nWelcome to the world of TeapotWare!"); } } TWBOOL TWHelloWorldApplet::Main() { while(m_window->ProcessEvent(TRUE)); return TRUE; } TWHelloWorldApplet::TWHelloWorldApplet() { m_window=NULL; }