예제 #1
0
void LifeFrame::OnOpen(wxCommandEvent& WXUNUSED(event))
{
    wxFileDialog filedlg(this,
                         _("Choose a file to open"),
                         wxEmptyString,
                         wxEmptyString,
                         _("Life patterns (*.lif)|*.lif|All files (*.*)|*.*"),
                         wxFD_OPEN | wxFD_FILE_MUST_EXIST);

    if (filedlg.ShowModal() == wxID_OK)
    {
        wxFileInputStream stream(filedlg.GetPath());
        LifeReader reader(stream);

        // the reader handles errors itself, no need to do anything here
        if (reader.IsOk())
        {
            // stop if running and put the pattern
            OnStop();
            m_life->Clear();
            m_life->SetPattern(reader.GetPattern());

            // recenter canvas
            m_canvas->Recenter(0, 0);
            m_tics = 0;
            UpdateInfoText();
        }
    }
}
예제 #2
0
void LifeFrame::OnStep()
{
    if (m_life->NextTic())
        m_tics++;
    else
        OnStop();

    m_canvas->DrawChanged();
    UpdateInfoText();
}
예제 #3
0
void LifeFrame::OnStep()
{
    if (m_life->NextTic())
    {
        m_tics++;
        m_canvas->Refresh();
        UpdateInfoText();
    }
    else
        OnStop();
}
예제 #4
0
void LifeFrame::OnSlider(wxScrollEvent& event)
{
    m_interval = event.GetPosition() * 100;

    if (m_running)
    {
        OnStop();
        OnStart();
    }

    UpdateInfoText();
}
예제 #5
0
파일: EpgDBUtil.cpp 프로젝트: abt8WG/EDCB
void CEpgDBUtil::AddShortEvent(EVENT_INFO* eventInfo, const AribDescriptor::CDescriptor* shortEvent)
{
	if( eventInfo->shortInfo == NULL ){
		eventInfo->shortInfo = new EPG_SHORT_EVENT_INFO;
	}
	{
		CARIB8CharDecode arib;
		string event_name = "";
		string text_char = "";
		const char* src;
		DWORD srcSize;
		src = shortEvent->GetStringOrEmpty(AribDescriptor::event_name_char, &srcSize);
		arib.PSISI((const BYTE*)src, srcSize, &event_name);
		src = shortEvent->GetStringOrEmpty(AribDescriptor::text_char, &srcSize);
		arib.PSISI((const BYTE*)src, srcSize, &text_char);
#ifdef DEBUG_EIT
		text_char = g_szDebugEIT + text_char;
#endif

		eventInfo->shortInfo->event_nameLength = UpdateInfoText(eventInfo->shortInfo->event_name, event_name.c_str());
		eventInfo->shortInfo->text_charLength = UpdateInfoText(eventInfo->shortInfo->text_char, text_char.c_str());
	}
}
예제 #6
0
파일: EpgDBUtil.cpp 프로젝트: abt8WG/EDCB
BOOL CEpgDBUtil::AddAudioComponent(EVENT_INFO* eventInfo, const vector<AribDescriptor::CDescriptor>* descriptorList)
{
	{
		WORD listSize = 0;
		for( size_t i=0; i<descriptorList->size(); i++ ){
			if( (*descriptorList)[i].GetNumber(AribDescriptor::descriptor_tag) == AribDescriptor::audio_component_descriptor ){
				listSize++;
			}
		}
		if( listSize == 0 ){
			return FALSE;
		}
		if( eventInfo->audioInfo == NULL ){
			eventInfo->audioInfo = new EPG_AUDIO_COMPONENT_INFO;
		}
		SAFE_DELETE_ARRAY(eventInfo->audioInfo->audioList);
		eventInfo->audioInfo->listSize = listSize;
		eventInfo->audioInfo->audioList = new EPG_AUDIO_COMPONENT_INFO_DATA[listSize];

		for( size_t i=0, j=0; j<eventInfo->audioInfo->listSize; i++ ){
			if( (*descriptorList)[i].GetNumber(AribDescriptor::descriptor_tag) == AribDescriptor::audio_component_descriptor ){
				const AribDescriptor::CDescriptor* audioComponent = &(*descriptorList)[i];
				EPG_AUDIO_COMPONENT_INFO_DATA& item = eventInfo->audioInfo->audioList[j++];

				item.stream_content = (BYTE)audioComponent->GetNumber(AribDescriptor::stream_content);
				item.component_type = (BYTE)audioComponent->GetNumber(AribDescriptor::component_type);
				item.component_tag = (BYTE)audioComponent->GetNumber(AribDescriptor::component_tag);

				item.stream_type = (BYTE)audioComponent->GetNumber(AribDescriptor::stream_type);
				item.simulcast_group_tag = (BYTE)audioComponent->GetNumber(AribDescriptor::simulcast_group_tag);
				item.ES_multi_lingual_flag = (BYTE)audioComponent->GetNumber(AribDescriptor::ES_multi_lingual_flag);
				item.main_component_flag = (BYTE)audioComponent->GetNumber(AribDescriptor::main_component_flag);
				item.quality_indicator = (BYTE)audioComponent->GetNumber(AribDescriptor::quality_indicator);
				item.sampling_rate = (BYTE)audioComponent->GetNumber(AribDescriptor::sampling_rate);


				CARIB8CharDecode arib;
				string text_char = "";
				DWORD srcSize;
				const char* src = audioComponent->GetStringOrEmpty(AribDescriptor::text_char, &srcSize);
				arib.PSISI((const BYTE*)src, srcSize, &text_char);
				item.text_charLength = UpdateInfoText(item.text_char, text_char.c_str());

			}
		}
	}

	return TRUE;
}
예제 #7
0
파일: EpgDBUtil.cpp 프로젝트: abt8WG/EDCB
void CEpgDBUtil::AddComponent(EVENT_INFO* eventInfo, const AribDescriptor::CDescriptor* component)
{
	if( eventInfo->componentInfo == NULL ){
		eventInfo->componentInfo = new EPG_COMPONENT_INFO;
	}
	{
		eventInfo->componentInfo->stream_content = (BYTE)component->GetNumber(AribDescriptor::stream_content);
		eventInfo->componentInfo->component_type = (BYTE)component->GetNumber(AribDescriptor::component_type);
		eventInfo->componentInfo->component_tag = (BYTE)component->GetNumber(AribDescriptor::component_tag);

		CARIB8CharDecode arib;
		string text_char = "";
		DWORD srcSize;
		const char* src = component->GetStringOrEmpty(AribDescriptor::text_char, &srcSize);
		arib.PSISI((const BYTE*)src, srcSize, &text_char);
		eventInfo->componentInfo->text_charLength = UpdateInfoText(eventInfo->componentInfo->text_char, text_char.c_str());

	}
}
예제 #8
0
void LifeFrame::OnSamples(wxCommandEvent& WXUNUSED(event))
{
    // stop if it was running
    OnStop();

    // dialog box
    LifeSamplesDialog dialog(this);

    if (dialog.ShowModal() == wxID_OK)
    {
        const LifePattern pattern = dialog.GetPattern();

        // put the pattern
        m_life->Clear();
        m_life->SetPattern(pattern);

        // recenter canvas
        m_canvas->Recenter(0, 0);
        m_tics = 0;
        UpdateInfoText();
    }
}
예제 #9
0
// OnMenu handles all events which don't have their own event handler
void LifeFrame::OnMenu(wxCommandEvent& event)
{
    switch (event.GetId())
    {
        case wxID_NEW:
        {
            // stop if it was running
            OnStop();
            m_life->Clear();
            m_canvas->Recenter(0, 0);
            m_tics = 0;
            UpdateInfoText();
            break;
        }
        case wxID_ABOUT:
        {
            LifeAboutDialog dialog(this);
            dialog.ShowModal();
            break;
        }
        case wxID_EXIT:
        {
            // true is to force the frame to close
            Close(true);
            break;
        }
        case ID_SHOWNAV:
        {
            bool checked = GetMenuBar()->GetMenu(1)->IsChecked(ID_SHOWNAV);
            if (m_navigator)
                m_navigator->Show(checked);
            break;
        }
        case ID_INFO:
        {
            wxString desc = m_life->GetDescription();

            if ( desc.empty() )
                desc = _("Not available");

            // should we make the description editable here?
            wxMessageBox(desc, _("Description"), wxOK | wxICON_INFORMATION);

            break;
        }
        case ID_START   : OnStart(); break;
        case ID_STEP    : OnStep(); break;
        case wxID_STOP  : OnStop(); break;
        case ID_TOPSPEED:
        {
            m_running = true;
            m_topspeed = true;
            UpdateUI();
            while (m_running && m_topspeed)
            {
                OnStep();
                wxYield();
            }
            break;
        }
    }
}
예제 #10
0
// frame constructor
LifeFrame::LifeFrame() :
  wxFrame( (wxFrame *) NULL, wxID_ANY, _("Life!"), wxDefaultPosition ),
  m_navigator(NULL)
{
    // frame icon
    SetIcon(wxICON(mondrian));

    // menu bar
    wxMenu *menuFile = new wxMenu(wxMENU_TEAROFF);
    wxMenu *menuView = new wxMenu(wxMENU_TEAROFF);
    wxMenu *menuGame = new wxMenu(wxMENU_TEAROFF);
    wxMenu *menuHelp = new wxMenu(wxMENU_TEAROFF);

    menuFile->Append(wxID_NEW, wxEmptyString, _("Start a new game"));
#if wxUSE_FILEDLG
    menuFile->Append(wxID_OPEN, wxEmptyString, _("Open an existing Life pattern"));
#endif
    menuFile->Append(ID_SAMPLES, _("&Sample game..."), _("Select a sample configuration"));
#if ! (defined(__SMARTPHONE__) || defined(__POCKETPC__))
    menuFile->AppendSeparator();
    menuFile->Append(wxID_EXIT);

    menuView->Append(ID_SHOWNAV, _("Navigation &toolbox"), _("Show or hide toolbox"), wxITEM_CHECK);
    menuView->Check(ID_SHOWNAV, true);
    menuView->AppendSeparator();
#endif

    menuView->Append(ID_ORIGIN, _("&Absolute origin"), _("Go to (0, 0)"));
    menuView->Append(ID_CENTER, _("&Center of mass"), _("Find center of mass"));
    menuView->Append(ID_NORTH, _("&North"), _("Find northernmost cell"));
    menuView->Append(ID_SOUTH, _("&South"), _("Find southernmost cell"));
    menuView->Append(ID_EAST, _("&East"), _("Find easternmost cell"));
    menuView->Append(ID_WEST, _("&West"), _("Find westernmost cell"));
    menuView->AppendSeparator();
    menuView->Append(wxID_ZOOM_IN, wxEmptyString, _("Zoom in"));
    menuView->Append(wxID_ZOOM_OUT, wxEmptyString, _("Zoom out"));
    menuView->Append(ID_INFO, _("&Description\tCtrl-D"), _("View pattern description"));

    menuGame->Append(ID_START, _("&Start\tCtrl-S"), _("Start"));
    menuGame->Append(ID_STEP, _("&Next\tCtrl-N"), _("Single step"));
    menuGame->Append(wxID_STOP, wxEmptyString, _("Stop"));
    menuGame->Enable(wxID_STOP, false);
    menuGame->AppendSeparator();
    menuGame->Append(ID_TOPSPEED, _("T&op speed!"), _("Go as fast as possible"));

    menuHelp->Append(wxID_ABOUT, _("&About\tCtrl-A"), _("Show about dialog"));

    wxMenuBar *menuBar = new wxMenuBar();
    menuBar->Append(menuFile, _("&File"));
    menuBar->Append(menuView, _("&View"));
    menuBar->Append(menuGame, _("&Game"));
    menuBar->Append(menuHelp, _("&Help"));
    SetMenuBar(menuBar);

    // tool bar
    wxBitmap tbBitmaps[7];

    tbBitmaps[0] = wxBITMAP(reset);
    tbBitmaps[1] = wxBITMAP(open);
    tbBitmaps[2] = wxBITMAP(zoomin);
    tbBitmaps[3] = wxBITMAP(zoomout);
    tbBitmaps[4] = wxBITMAP(info);
    tbBitmaps[5] = wxBITMAP(play);
    tbBitmaps[6] = wxBITMAP(stop);

    wxToolBar *toolBar = CreateToolBar();
    toolBar->SetMargins(5, 5);
    toolBar->SetToolBitmapSize(wxSize(16, 16));

    ADD_TOOL(wxID_NEW, tbBitmaps[0], wxGetStockLabel(wxID_NEW, wxSTOCK_NOFLAGS), _("Start a new game"));
#ifndef __POCKETPC__
#if wxUSE_FILEDLG
    ADD_TOOL(wxID_OPEN, tbBitmaps[1], wxGetStockLabel(wxID_OPEN, wxSTOCK_NOFLAGS), _("Open an existing Life pattern"));
#endif // wxUSE_FILEDLG

    toolBar->AddSeparator();
    ADD_TOOL(wxID_ZOOM_IN, tbBitmaps[2], wxGetStockLabel(wxID_ZOOM_IN, wxSTOCK_NOFLAGS), _("Zoom in"));
    ADD_TOOL(wxID_ZOOM_OUT, tbBitmaps[3], wxGetStockLabel(wxID_ZOOM_OUT, wxSTOCK_NOFLAGS), _("Zoom out"));
    ADD_TOOL(ID_INFO, tbBitmaps[4], _("Description"), _("Show description"));
    toolBar->AddSeparator();
#endif // __POCKETPC__
    ADD_TOOL(ID_START, tbBitmaps[5], _("Start"), _("Start"));
    ADD_TOOL(wxID_STOP, tbBitmaps[6], _("Stop"), _("Stop"));

    toolBar->Realize();
    toolBar->EnableTool(wxID_STOP, false);    // must be after Realize() !

#if wxUSE_STATUSBAR
    // status bar
    CreateStatusBar(2);
    SetStatusText(_("Welcome to Life!"));
#endif // wxUSE_STATUSBAR

    // game and timer
    m_life     = new Life();
    m_timer    = new wxTimer(this, ID_TIMER);
    m_running  = false;
    m_topspeed = false;
    m_interval = 500;
    m_tics     = 0;

    // We use two different panels to reduce flicker in wxGTK, because
    // some widgets (like wxStaticText) don't have their own X11 window,
    // and thus updating the text would result in a refresh of the canvas
    // if they belong to the same parent.

    wxPanel *panel1 = new wxPanel(this, wxID_ANY);
    wxPanel *panel2 = new wxPanel(this, wxID_ANY);

    // canvas
    m_canvas = new LifeCanvas(panel1, m_life);

    // info panel
    m_text = new wxStaticText(panel2, wxID_ANY,
        wxEmptyString,
        wxDefaultPosition,
        wxDefaultSize,
        wxALIGN_CENTER | wxST_NO_AUTORESIZE);

    wxSlider *slider = new wxSlider(panel2, ID_SLIDER,
        5, 1, 10,
        wxDefaultPosition,
        wxSize(200, wxDefaultCoord),
        wxSL_HORIZONTAL | wxSL_AUTOTICKS);

    UpdateInfoText();

    // component layout
    wxBoxSizer *sizer1 = new wxBoxSizer(wxVERTICAL);
    wxBoxSizer *sizer2 = new wxBoxSizer(wxVERTICAL);
    wxBoxSizer *sizer3 = new wxBoxSizer(wxVERTICAL);

#if wxUSE_STATLINE
    sizer1->Add( new wxStaticLine(panel1, wxID_ANY), 0, wxGROW );
#endif // wxUSE_STATLINE
    sizer1->Add( m_canvas, 1, wxGROW | wxALL, 2 );
#if wxUSE_STATLINE
    sizer1->Add( new wxStaticLine(panel1, wxID_ANY), 0, wxGROW );
#endif // wxUSE_STATLINE
    panel1->SetSizer( sizer1 );
    sizer1->Fit( panel1 );

    sizer2->Add( m_text, 0, wxGROW | wxTOP, 4 );
    sizer2->Add( slider, 0, wxCENTRE | wxALL, 4 );

    panel2->SetSizer( sizer2 );
    sizer2->Fit( panel2 );

    sizer3->Add( panel1, 1, wxGROW );
    sizer3->Add( panel2, 0, wxGROW );
    SetSizer( sizer3 );

#ifndef __WXWINCE__
    sizer3->Fit( this );

    // set minimum frame size
    sizer3->SetSizeHints( this );

    // navigator frame - not appropriate for small devices
    m_navigator = new LifeNavigator(this);
#endif

}
예제 #11
0
파일: EpgDBUtil.cpp 프로젝트: abt8WG/EDCB
BOOL CEpgDBUtil::AddExtEvent(EVENT_INFO* eventInfo, const vector<AribDescriptor::CDescriptor>* descriptorList)
{
	{
		BOOL foundFlag = FALSE;
		CARIB8CharDecode arib;
		string extendText = "";
		string itemDescBuff = "";
		string itemBuff = "";
		//text_lengthは0で運用される
//		string textBuff = "";

		for( size_t i=0; i<descriptorList->size(); i++ ){
			if( (*descriptorList)[i].GetNumber(AribDescriptor::descriptor_tag) == AribDescriptor::extended_event_descriptor ){
				foundFlag = TRUE;
				const AribDescriptor::CDescriptor* extEvent = &(*descriptorList)[i];
				AribDescriptor::CDescriptor::CLoopPointer lp;
				if( extEvent->EnterLoop(lp) ){
					for( DWORD j=0; extEvent->SetLoopIndex(lp, j); j++ ){
						const char* src;
						DWORD srcSize;
						src = extEvent->GetStringOrEmpty(AribDescriptor::item_description_char, &srcSize, lp);
						if( srcSize > 0 ){
							//if( textBuff.size() > 0 ){
							//	string buff = "";
							//	arib.PSISI((const BYTE*)textBuff.c_str(), textBuff.length(), &buff);
							//	buff += "\r\n";
							//	extendText += buff;
							//	textBuff = "";
							//}
							if( itemBuff.size() > 0 ){
								string buff = "";
								arib.PSISI((const BYTE*)itemBuff.c_str(), (DWORD)itemBuff.length(), &buff);
								buff += "\r\n";
								extendText += buff;
								itemBuff = "";
							}

							itemDescBuff += src;
						}
						src = extEvent->GetStringOrEmpty(AribDescriptor::item_char, &srcSize, lp);
						if( srcSize > 0 ){
							//if( textBuff.size() > 0 ){
							//	string buff = "";
							//	arib.PSISI((const BYTE*)textBuff.c_str(), textBuff.length(), &buff);
							//	buff += "\r\n";
							//	extendText += buff;
							//	textBuff = "";
							//}
							if( itemDescBuff.size() > 0 ){
								string buff = "";
								arib.PSISI((const BYTE*)itemDescBuff.c_str(), (DWORD)itemDescBuff.length(), &buff);
								buff += "\r\n";
								extendText += buff;
								itemDescBuff = "";
							}

							itemBuff += src;
						}
					}
				}
				//if( extEvent->text_length > 0 ){
				//	if( itemDescBuff.size() > 0 ){
				//		string buff = "";
				//		arib.PSISI((const BYTE*)itemDescBuff.c_str(), itemDescBuff.length(), &buff);
				//		buff += "\r\n";
				//		extendText += buff;
				//		itemDescBuff = "";
				//	}
				//	if( itemBuff.size() > 0 ){
				//		string buff = "";
				//		arib.PSISI((const BYTE*)itemBuff.c_str(), itemBuff.length(), &buff);
				//		buff += "\r\n";
				//		extendText += buff;
				//		itemBuff = "";
				//	}

				//	textBuff += extEvent->text_char;
				//}
			}
		}

		if( itemDescBuff.size() > 0 ){
			string buff = "";
			arib.PSISI((const BYTE*)itemDescBuff.c_str(), (DWORD)itemDescBuff.length(), &buff);
			buff += "\r\n";
			extendText += buff;
			itemDescBuff = "";
		}
		if( itemBuff.size() > 0 ){
			string buff = "";
			arib.PSISI((const BYTE*)itemBuff.c_str(), (DWORD)itemBuff.length(), &buff);
			buff += "\r\n";
			extendText += buff;
			itemBuff = "";
		}
		//if( textBuff.size() > 0 ){
		//	string buff = "";
		//	arib.PSISI((const BYTE*)textBuff.c_str(), textBuff.length(), &buff);
		//	buff += "\r\n";
		//	extendText += buff;
		//	textBuff = "";
		//}

		if( foundFlag == FALSE ){
			return FALSE;
		}
		if( eventInfo->extInfo == NULL ){
			eventInfo->extInfo = new EPG_EXTENDED_EVENT_INFO;
		}
#ifdef DEBUG_EIT
		extendText = g_szDebugEIT + extendText;
#endif
		eventInfo->extInfo->text_charLength = UpdateInfoText(eventInfo->extInfo->text_char, extendText.c_str());
	}

	return TRUE;
}