OSDN Git Service

fix build system ofmoflib1 and saisei1
[moflib/moflib.git] / saisei-1.0 / src / oldcode / MyInstructionSet.cpp~
1 #include "MyInstructionSet.hpp"
2 #include "mof/ImageTileWidgetView.hpp"
3 #include "mof/utilities.hpp"
4 #include "mof/LayoutManager.hpp"
5 #include "mof/Deleter.hpp"
6 #include "mof/mofInput.hpp"
7 #include "mof/mofGraphics.hpp"
8 #include <boost/bind.hpp>
9 #include "mof/EventScheduler.hpp"
10 #include <list>
11 #include "mof/ConsoleIO.hpp"
12 #include "mof/widgets.hpp"
13
14 struct MyInstructionSet::Impl
15 {
16     std::list<boost::weak_ptr<mof::MessageWidget> > inactiveResources;
17     mof::EventScheduler scheduler;
18     std::list<boost::shared_ptr<mof::MessageWidget> > messages;
19     
20     Impl()
21     {
22     }
23     
24     ~Impl()
25     {
26     }
27     
28     
29 };
30
31 MyInstructionSet::MyInstructionSet(  )
32 : m_pImpl(new Impl() )
33 {
34 }
35
36
37 MyInstructionSet::~MyInstructionSet( )
38 {
39 }
40 //{{{ createMessageWidget
41 boost::shared_ptr<mof::MessageWidget>
42 MyInstructionSet::createMessageWidget( ) 
43 {
44     mof::LayoutManager* pLayout = new mof::LayoutManager( mof::LayoutManager::HORIZONTAL , 1);
45         mof::WidgetView* pBackgroundView = new mof::ImageTileWidgetView( _T("image/frame0.png")  );
46         
47         
48         boost::shared_ptr<mof::MessageWidget> p
49         (
50             new mof::MessageWidget
51             (
52                     pBackgroundView ,
53                     mof::Rectangle<int>(70+20 , 300 , 570+20 , 450) , pLayout
54                 )
55         );
56             
57         m_pImpl->messages.push_back(p);
58         return p;
59         
60 }
61 //}}}
62 //{{{ addMessageWidgetPage
63 int
64 MyInstructionSet::addMessageWidgetPage
65
66     boost::shared_ptr<mof::MessageWidget>& message , 
67     const mof::tstring &title , 
68     const mof::tstring &text
69
70 {
71         mof::PageRequest page(text , mof::Font(_T("\94~UI\83S\83V\83b\83N") , 25) );
72         message->addPage( page );
73     return 30;// TODO \83y\81[\83W\8aJ\82­\82Ì\82É\82©\82©\82é\8e\9e\8aÔ  
74 }
75 //}}}
76
77 void MyInstructionSet::inactive( boost::shared_ptr<mof::MessageWidget>& message ) 
78 {   
79
80         /*mof::Deleter<mof::MessageWidget> del(message);
81                                 
82         m_pImpl->inactiveResources.push_back(del.getWeak());
83         m_pImpl->scheduler.addEvent( 40 , del );*/
84         //m_pImpl->scheduler.addEvent( 40 , boost::bind( &mof::Interpreter::doNextCommand , this ) );
85 }
86
87 void MyInstructionSet::update( )
88 {
89     m_pImpl->scheduler.update( );
90     foreach(boost::weak_ptr<mof::MessageWidget>& resource , m_pImpl->inactiveResources)
91         {
92             if(resource.lock())resource.lock()->update();
93         }
94 }
95   
96 void MyInstructionSet::draw() const
97 {
98     foreach(boost::shared_ptr<mof::MessageWidget>& resource , m_pImpl->messages )
99     {
100         resource->draw();
101     }
102     foreach(boost::weak_ptr<mof::MessageWidget>& resource , m_pImpl->inactiveResources)
103         {
104             if(resource.lock())resource.lock()->draw();
105         }
106 }
107
108