Skip to content

Commit

Permalink
Update Release
Browse files Browse the repository at this point in the history
  • Loading branch information
vczh committed Nov 1, 2015
1 parent 5ced708 commit 84ce8c0
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 7 deletions.
11 changes: 10 additions & 1 deletion Tutorial/GacUI_Layout/RichTextEmbedding/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
return SetupWindowsDirect2DRenderer();
}

class ViewModel : public Object, public virtual demo::IViewModel
{
public:
void OpenUrl(WString url)override
{
ShellExecute(NULL, L"OPEN", url.Buffer(), NULL, NULL, SW_MAXIMIZE);
}
};

void GuiMain()
{
{
Expand All @@ -17,7 +26,7 @@ void GuiMain()
auto resource = GuiResource::LoadPrecompiledBinary(fileStream, errors);
GetInstanceLoaderManager()->SetResource(L"Resource", resource);
}
demo::MainWindow window;
demo::MainWindow window(new ViewModel);
window.MoveToScreenCenter();
GetApplication()->Run(&window);
}
6 changes: 5 additions & 1 deletion Tutorial/GacUI_Layout/RichTextEmbedding/UI/MainWindow.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Instance ref.CodeBehind="false" ref.Class="demo::MainWindow">
<ref.Parameter Name="ViewModel" Class="demo::IViewModel"/>
<Window Text="RichTextEmbedding" ClientSize="x:480 y:320">
<att.BoundsComposition-set PreferredMinSize="x:480 y:640"/>
<att.ContainerComposition-set MinSizeLimitation="LimitToElementAndChildren"/>

<DocumentViewer EditMode="Selectable" Document-uri="res://EmbeddedDocument/Document">
<DocumentViewer ref.Name="documentViewer" EditMode="ViewOnly" Document-uri="res://EmbeddedDocument/Document">
<att.BoundsComposition-set AlignmentToParent="left:5 top:5 right:5 bottom:5"/>
<ev.ActiveHyperlinkExecuted-eval>
ViewModel.OpenUrl(documentViewer.ActiveHyperlinkReference);
</ev.ActiveHyperlinkExecuted-eval>
<DocumentItem Name="Button">
<Button Text="Button"/>
</DocumentItem>
Expand Down
15 changes: 15 additions & 0 deletions Tutorial/GacUI_Layout/RichTextEmbedding/UI/Resource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,21 @@
<Doc content="File" name="Document">Document.xml</Doc>
</Folder>
<Folder name="MainWindow">
<Script name="ViewModelResource">
<Workflow-ViewModel>
<![CDATA[
module viewmodel;
namespace demo
{
interface IViewModel
{
func OpenUrl(url : string) : void;
}
}
]]>
</Workflow-ViewModel>
</Script>
<Instance content="File" name="MainWindowResource">MainWindow.xml</Instance>
</Folder>
</Resource>
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ namespace demo

// #endregion CLASS_MEMBER_GUIEVENT_HANDLER

MainWindow::MainWindow()
MainWindow::MainWindow(Ptr<demo::IViewModel> ViewModel)
{
InitializeComponents();
InitializeComponents(ViewModel);
}

MainWindow::~MainWindow()
Expand All @@ -35,11 +35,19 @@ namespace vl
namespace description
{
#define _ ,
IMPL_CPP_TYPE_INFO(demo::IViewModel)
IMPL_CPP_TYPE_INFO(demo::MainWindow)

BEGIN_CLASS_MEMBER(demo::IViewModel)
CLASS_MEMBER_BASE(vl::reflection::IDescriptable)
CLASS_MEMBER_METHOD(OpenUrl, { L"url" });
END_CLASS_MEMBER(demo::IViewModel)

BEGIN_CLASS_MEMBER(demo::MainWindow)
CLASS_MEMBER_BASE(vl::presentation::controls::GuiWindow)
CLASS_MEMBER_CONSTRUCTOR(demo::MainWindow*(), NO_PARAMETER)
CLASS_MEMBER_CONSTRUCTOR(demo::MainWindow*(Ptr<demo::IViewModel>), { L"ViewModel" })

CLASS_MEMBER_PROPERTY_READONLY_FAST(ViewModel)
END_CLASS_MEMBER(demo::MainWindow)

#undef _
Expand All @@ -49,6 +57,7 @@ namespace vl
public:
void Load(ITypeManager* manager)
{
ADD_TYPE_INFO(demo::IViewModel)
ADD_TYPE_INFO(demo::MainWindow)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,47 @@ DO NOT MODIFY

namespace demo
{
class IViewModel;
class MainWindow;

class IViewModel : public virtual vl::reflection::IDescriptable, public vl::reflection::Description<IViewModel>
{
public:
virtual void OpenUrl(vl::WString url) = 0;
};

template<typename TImpl>
class MainWindow_ : public vl::presentation::controls::GuiWindow, public vl::presentation::GuiInstancePartialClass<vl::presentation::controls::GuiWindow>, public vl::reflection::Description<TImpl>
{
friend struct vl::reflection::description::CustomTypeDescriptorSelector<TImpl>;
private:
Ptr<demo::IViewModel> ViewModel_;
protected:
vl::presentation::controls::GuiDocumentViewer* documentViewer;

void InitializeComponents()
void InitializeComponents(Ptr<demo::IViewModel> ViewModel)
{
ViewModel_ = ViewModel;
if (InitializeFromResource())
{
GUI_INSTANCE_REFERENCE(documentViewer);
}
else
{
ViewModel_ = 0;
}
}
public:
MainWindow_()
:vl::presentation::GuiInstancePartialClass<vl::presentation::controls::GuiWindow>(L"demo::MainWindow")
,vl::presentation::controls::GuiWindow(vl::presentation::theme::GetCurrentTheme()->CreateWindowStyle())
,documentViewer(0)
{
}

Ptr<demo::IViewModel> GetViewModel()
{
return ViewModel_;
}
};

Expand All @@ -48,6 +66,7 @@ namespace vl
{
namespace description
{
DECL_TYPE_INFO(demo::IViewModel)
DECL_TYPE_INFO(demo::MainWindow)

}
Expand All @@ -64,7 +83,7 @@ namespace demo
// #region CLASS_MEMBER_GUIEVENT_HANDLER (DO NOT PUT OTHER CONTENT IN THIS #region.)
// #endregion CLASS_MEMBER_GUIEVENT_HANDLER
public:
MainWindow();
MainWindow(Ptr<demo::IViewModel> ViewModel);
~MainWindow();
};
}
Expand Down
Binary file modified Tutorial/GacUI_Layout/UIRes/RichTextEmbedding.bin
Binary file not shown.

0 comments on commit 84ce8c0

Please sign in to comment.