Esempio n. 1
1
LIB_VIEW_FRAME::LIB_VIEW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType,
                                const wxString& aLibraryName ) :
    SCH_BASE_FRAME( aKiway, aParent, aFrameType, _( "Symbol Library Browser" ),
                    wxDefaultPosition, wxDefaultSize,
                    aFrameType == FRAME_SCH_VIEWER_MODAL ? LIB_VIEW_STYLE_MODAL : LIB_VIEW_STYLE,
                    aFrameType == FRAME_SCH_VIEWER_MODAL ? LIB_VIEW_NAME_MODAL : LIB_VIEW_NAME ),
    m_libList( nullptr ),
    m_cmpList( nullptr ),
    m_previewItem( nullptr )
{
    wxASSERT( aFrameType == FRAME_SCH_VIEWER || aFrameType == FRAME_SCH_VIEWER_MODAL );

    if( aFrameType == FRAME_SCH_VIEWER_MODAL )
        SetModal( true );

    // Force the frame name used in config. the lib viewer frame has a name
    // depending on aFrameType (needed to identify the frame by wxWidgets),
    // but only one configuration is preferable.
    m_configFrameName = LIB_VIEW_NAME;

    // Give an icon
    wxIcon  icon;
    icon.CopyFromBitmap( KiBitmap( library_browse_xpm ) );
    SetIcon( icon );

    m_hotkeysDescrList = g_Viewlib_Hotkeys_Descr;
    m_libListWidth = 200;
    m_cmpListWidth = 300;
    m_listPowerCmpOnly = false;
    SetShowElectricalType( true );

    // Initialize grid id to the default value (50 mils):
    m_LastGridSizeId = ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000;

    SetScreen( new SCH_SCREEN( aKiway ) );
    GetScreen()->m_Center = true;      // Axis origin centered on screen.
    LoadSettings( config() );

    SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );

    // Menu bar is not mandatory: uncomment/comment the next line
    // to add/remove the menubar
    ReCreateMenuBar();
    ReCreateHToolbar();
    ReCreateVToolbar();

    m_libList = new wxListBox( this, ID_LIBVIEW_LIB_LIST, wxDefaultPosition, wxDefaultSize,
                               0, NULL, wxLB_HSCROLL | wxNO_BORDER );

    m_cmpList = new wxListBox( this, ID_LIBVIEW_CMP_LIST, wxDefaultPosition, wxDefaultSize,
                               0, NULL, wxLB_HSCROLL | wxNO_BORDER );

    if( aLibraryName.empty() )
    {
        ReCreateListLib();
    }
    else
    {
        m_libraryName = aLibraryName;
        m_entryName.Clear();
        m_unit = 1;
        m_convert = 1;
    }

    m_selection_changed = false;

    DisplayLibInfos();

    m_auimgr.SetManagedWindow( this );
    m_auimgr.SetArtProvider( new EDA_DOCKART( this ) );

    // Manage main toolbar
    m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
    m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );

    m_auimgr.AddPane( m_libList, EDA_PANE().Palette().Name( "Libraries" ).Left().Layer(3)
                      .CaptionVisible( false ).MinSize( 80, -1 ).BestSize( m_libListWidth, -1 ) );
    m_auimgr.AddPane( m_cmpList, EDA_PANE().Palette().Name( "Symbols" ).Left().Layer(1)
                      .CaptionVisible( false ).MinSize( 80, -1 ).BestSize( m_cmpListWidth, -1 ) );

    m_auimgr.AddPane( m_canvas->GetWindow(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );

    m_auimgr.GetPane( m_libList ).Show( aLibraryName.empty() );

    m_auimgr.Update();

    setupTools();
    GetToolManager()->RunAction( "common.Control.gridPreset", true, m_LastGridSizeId );
    GetToolManager()->RunAction( "common.Control.zoomFitScreen", true );

    if( !IsModal() )        // For modal mode, calling ShowModal() will show this frame
    {
        Raise();
        Show( true );
    }

    SyncView();
    GetGalCanvas()->GetViewControls()->SetSnapping( true );
    GetGalCanvas()->GetGAL()->SetAxesEnabled( true );
    GetGalCanvas()->GetGAL()->SetGridVisibility( IsGridVisible() );

    // Set the working/draw area size to display a symbol to a reasonable value:
    // A 450mm x 450mm with a origin at the area center looks like a large working area
    double max_size_x = Millimeter2iu( 450 );
    double max_size_y = Millimeter2iu( 450 );
    BOX2D bbox;
    bbox.SetOrigin( -max_size_x /2, -max_size_y/2 );
    bbox.SetSize( max_size_x, max_size_y );
    GetCanvas()->GetView()->SetBoundary( bbox );
}
Esempio n. 2
0
//---------------------------------------------------------
CSAGA_Frame::CSAGA_Frame(void)
	: wxMDIParentFrame(NULL, ID_WND_MAIN, SAGA_CAPTION, wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE|wxHSCROLL|wxVSCROLL|wxFRAME_NO_WINDOW_MENU)
{
	//-----------------------------------------------------
	g_pSAGA_Frame		= this;

	m_nTopWindows		= 0;
	m_pTopWindows		= NULL;

	m_pINFO				= NULL;
	m_pData_Source		= NULL;
	m_pActive			= NULL;
	m_pWKSP				= NULL;

	SG_Set_UI_Callback	(Get_Callback());

	SetIcon				(IMG_Get_Icon(ID_IMG_SAGA_ICON_32));

	SetDropTarget		(new CSAGA_Frame_DropTarget);

	//-----------------------------------------------------
	int		STATUSBAR_Sizes[STATUSBAR_COUNT]	= {	-1, -1, 90, 90, 90, -1	};

	CreateStatusBar		(STATUSBAR_COUNT);
	SetStatusWidths		(STATUSBAR_COUNT, STATUSBAR_Sizes);
	SetStatusBarPane	(STATUSBAR_DEFAULT);
	StatusBar_Set_Text	(_TL("ready"));

	m_pProgressBar		= ((CSAGA_Frame_StatusBar *)GetStatusBar())->m_pProgressBar;

	//-----------------------------------------------------
	m_pLayout			= new wxAuiManager(this);

	m_pLayout->GetArtProvider()->SetColor	(wxAUI_DOCKART_ACTIVE_CAPTION_COLOUR,
		wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION)
	);

	m_pLayout->GetArtProvider()->SetColor	(wxAUI_DOCKART_INACTIVE_CAPTION_COLOUR,
		wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)
	);

	m_pLayout->GetArtProvider()->SetMetric	(wxAUI_DOCKART_GRADIENT_TYPE	, wxAUI_GRADIENT_NONE);
	m_pLayout->GetArtProvider()->SetMetric	(wxAUI_DOCKART_CAPTION_SIZE		, 14);

	m_pLayout->SetFlags(m_pLayout->GetFlags() ^ wxAUI_MGR_TRANSPARENT_DRAG);
//	m_pLayout->SetFlags(m_pLayout->GetFlags() ^ wxAUI_MGR_ALLOW_ACTIVE_PANE);

	//-----------------------------------------------------
	_Bar_Add(m_pINFO		= new CINFO       (this), 0, 0);	m_pINFO			->Add_Pages();
	_Bar_Add(m_pWKSP		= new CWKSP       (this), 2, 1);	m_pWKSP			->Add_Pages();
	_Bar_Add(m_pData_Source	= new CData_Source(this), 2, 1);	m_pData_Source	->Add_Pages();
	_Bar_Add(m_pActive		= new CACTIVE     (this), 2, 0);	m_pActive		->Add_Pages();

	//-----------------------------------------------------
	_Create_MenuBar();

	//-----------------------------------------------------
	m_pTB_Main			= 						  _Create_ToolBar();
	m_pTB_Map			= CVIEW_Map				::_Create_ToolBar();
	m_pTB_Map_3D		= CVIEW_Map_3D			::_Create_ToolBar();
	m_pTB_Layout		= CVIEW_Layout			::_Create_ToolBar();
	m_pTB_Table			= CVIEW_Table			::_Create_ToolBar();
	m_pTB_Diagram		= CVIEW_Table_Diagram	::_Create_ToolBar();
	m_pTB_Histogram		= CVIEW_Histogram		::_Create_ToolBar();
	m_pTB_ScatterPlot	= CVIEW_ScatterPlot		::_Create_ToolBar();

	//-----------------------------------------------------
	m_pLayout->GetPane(GetClientWindow()).Show().Center();

	wxString	s;

	if( CONFIG_Read(wxT("/FL"), wxT("MANAGER"), s) )
	{
		m_pLayout->LoadPerspective(s);
	}

	_Bar_Show(m_pTB_Main, true);

	//-----------------------------------------------------
	m_pLayout->Update();

#if !defined(_SAGA_LINUX)
	Show(true);
#endif

	int		x, y, dx, dy;
	long	l;

	x	= CONFIG_Read(wxT("/FL"), wxT("X" ), l) ? l : -1;
	y	= CONFIG_Read(wxT("/FL"), wxT("Y" ), l) ? l : -1;
	dx	= CONFIG_Read(wxT("/FL"), wxT("DX"), l) ? l : 800;
	dy	= CONFIG_Read(wxT("/FL"), wxT("DY"), l) ? l : 600;

	SetSize(x, y, dx, dy);

	if( !(CONFIG_Read(wxT("/FL"), wxT("STATE"), l) && l == 0) )
	{
		Maximize();
	}

#if defined(_SAGA_LINUX)
	Show(true);
#endif

	Update();

	//-----------------------------------------------------
	if( g_pSAGA->argc <= 1 && g_pData->Initialise() )
	{
		Refresh(false);
	}

	ProgressBar_Set_Position(0);
}
Esempio n. 3
0
SettingsWindow::SettingsWindow(BRect frame): BWindow(frame, "Settings",
									 B_FLOATING_WINDOW_LOOK,B_FLOATING_SUBSET_WINDOW_FEEL,
									 B_ASYNCHRONOUS_CONTROLS|B_NOT_ZOOMABLE|B_NOT_RESIZABLE)
{
	view = new BView(Bounds(), "Settings View", B_FOLLOW_ALL_SIDES, B_WILL_DRAW);
	BRect the_rect = Bounds();
	the_rect.InsetBy(5.0f, 5.0f);
	float rectHOffset = frame.Width() / 2.0f - 2.0f;
	float rectVOffset = 18.0f;
	char buffer[10];

	the_rect.right = the_rect.left + rectHOffset;
	the_rect.bottom = the_rect.top + rectVOffset;
	
	gState->Register(this);
	 
	
	if (gState->LockAsReader())
	{
		sprintf(buffer,FLOAT_FORMAT, ixMin);	
		XMinBox = new BTextControl( the_rect, "xMin", "x-Min", buffer, new BMessage(XMIN_CHG));
		XMinBox->SetTarget(this); 
		XMinBox->SetDivider(30);
		view->AddChild(XMinBox);
		
		the_rect.OffsetBy(rectHOffset + 4,0);
		sprintf(buffer,FLOAT_FORMAT, ixMax);
		XMaxBox = new BTextControl( the_rect, "xMax", "x-Max", buffer, new BMessage(XMAX_CHG));
		XMaxBox->SetTarget(this);
		XMaxBox->SetDivider(30);
		view->AddChild(XMaxBox);
		
		the_rect.OffsetBy(-(rectHOffset + 4.0f), XMinBox->Bounds().Height() + 4.0f);
		sprintf(buffer,FLOAT_FORMAT, iyMin);	
		YMinBox = new BTextControl( the_rect, "yMin", "y-Min", buffer, new BMessage(YMIN_CHG));
		YMinBox->SetTarget(this);
		YMinBox->SetDivider(30);
		view->AddChild(YMinBox);
		
		the_rect.OffsetBy(rectHOffset + 4.0f, 0.0f);
		sprintf(buffer,FLOAT_FORMAT, iyMax);	
		YMaxBox = new BTextControl( the_rect, "yMax", "y-Max", buffer, new BMessage(YMAX_CHG));
		YMaxBox->SetTarget(this);
		YMaxBox->SetDivider(30);
		view->AddChild(YMaxBox);
				
		the_rect.OffsetBy(-(rectHOffset + 4.0f), YMaxBox->Bounds().Height()+4.0f);
		sprintf(buffer,FLOAT_FORMAT, gState->TellxStep());
		XStepBox = new BTextControl(the_rect,"x step", "x step", buffer, new BMessage(XSTEP_CHG));
		XStepBox->SetDivider(35);
		XStepBox->SetTarget(this);
//		XStepBox->ResizeToPreferred();
		view->AddChild(XStepBox);
		
		the_rect.OffsetBy(rectHOffset +4.0f,0.0f);
		sprintf(buffer,FLOAT_FORMAT, gState->TellyStep());
		YStepBox = new BTextControl(the_rect,"y step", "y step", buffer, new BMessage(YSTEP_CHG));
		YStepBox->SetDivider(35);
		YStepBox->SetTarget(this);
//		YStepBox->ResizeToPreferred();
		view->AddChild(YStepBox);
		
		the_rect.OffsetBy(-(rectHOffset+4.0f),XStepBox->Bounds().Height()+4.0f);
		sprintf(buffer,FLOAT_FORMAT, gState->TellThetaStep());
		ThetaStepBox = new BTextControl(the_rect,"theta step", "theta step", buffer, new BMessage(THETA_STEP_CHG));
		ThetaStepBox->SetDivider(50);
		ThetaStepBox->SetTarget(this);
//		ThetaStepBox->ResizeToPreferred();
		view->AddChild(ThetaStepBox);
		
		the_rect.OffsetBy(0,ThetaStepBox->Bounds().Height()+4.0f);
		sprintf(buffer,FLOAT_FORMAT, gState->TellThetaStart());
		ThetaStartBox = new BTextControl(the_rect,"theta start", "theta start", buffer, new BMessage(THETA_START_CHG));
		ThetaStartBox->SetDivider(53);
		ThetaStartBox->SetTarget(this);
//		ThetaStartBox->ResizeToPreferred();
		view->AddChild(ThetaStartBox);

		the_rect.OffsetBy(rectHOffset+4.0f,0.0f);
		sprintf(buffer,FLOAT_FORMAT, gState->TellThetaStop());
		ThetaStopBox = new BTextControl(the_rect,"theta stop", "theta stop", buffer, new BMessage(THETA_STOP_CHG));
		ThetaStopBox->SetDivider(50);
		ThetaStopBox->SetTarget(this);
//		ThetaStopBox->ResizeToPreferred();
		view->AddChild(ThetaStopBox);

		the_rect.OffsetBy(-(rectHOffset+4.0f),ThetaStartBox->Bounds().Height()+4.0f);
		sprintf(buffer,FLOAT_FORMAT, gState->TellTStep());
		TStepBox = new BTextControl(the_rect,"t step", "t step", buffer, new BMessage(T_STEP_CHG));
		TStepBox->SetDivider(35);
		TStepBox->SetTarget(this);
//		TStepBox->ResizeToPreferred();
		view->AddChild(TStepBox);
		
		the_rect.OffsetBy(0,TStepBox->Bounds().Height()+4.0f);
		sprintf(buffer,FLOAT_FORMAT, gState->TellTStart());
		TStartBox = new BTextControl(the_rect,"t start", "t start", buffer, new BMessage(T_START_CHG));
		TStartBox->SetDivider(35);
		TStartBox->SetTarget(this);
//		TStartBox->ResizeToPreferred();
		view->AddChild(TStartBox);

		the_rect.OffsetBy(rectHOffset+4.0f,0.0f);
		sprintf(buffer,FLOAT_FORMAT, gState->TellTStop());
		TStopBox = new BTextControl(the_rect,"t stop", "t stop", buffer, new BMessage(T_STOP_CHG));
		TStopBox->SetDivider(35);
		TStopBox->SetTarget(this);
//		TStopBox->ResizeToPreferred();
		view->AddChild(TStopBox);
	
		gState->UnlockAsReader();
	}
	
	
	
	view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	
	AddChild(view);
	
	ResizeTo(XMinBox->Bounds().Width() + XMaxBox->Bounds().Width() + 4.0f + 10.0f, XMinBox->Bounds().Height()*7+4.0f+ 4.0f +4.0f+4.0f+4.0f+4.0f+ 10.0f);

	Show();
	
	return;
}
void PointCloudSettingsControl::show(const bool toBeShown)
{
	Show(toBeShown);
}
Esempio n. 5
0
// Draws a text in rect.
void GfxText16::Box(const char *text, uint16 languageSplitter, bool show, const Common::Rect &rect, TextAlignment alignment, GuiResourceId fontId) {
	int16 textWidth, maxTextWidth, textHeight, charCount;
	int16 offset = 0;
	int16 hline = 0;
	GuiResourceId previousFontId = GetFontId();
	int16 previousPenColor = _ports->_curPort->penClr;
	bool doubleByteMode = false;
	const char *curTextPos = text;
	const char *curTextLine = text;

	if (fontId != -1)
		SetFont(fontId);
	else
		fontId = previousFontId;

	// Reset reference code rects
	_codeRefRects.clear();
	_codeRefTempRect.left = _codeRefTempRect.top = -1;

	maxTextWidth = 0;
	while (*curTextPos) {
		// We need to check for Shift-JIS every line
		//  Police Quest 2 PC-9801 often draws English + Japanese text during the same call
		if (g_sci->getLanguage() == Common::JA_JPN) {
			if (SwitchToFont900OnSjis(curTextPos, languageSplitter))
				doubleByteMode = true;
		}

		charCount = GetLongest(curTextPos, rect.width(), fontId);
		if (charCount == 0)
			break;
		Width(curTextLine, 0, charCount, fontId, textWidth, textHeight, true);
		maxTextWidth = MAX<int16>(maxTextWidth, textWidth);
		switch (alignment) {
		case SCI_TEXT16_ALIGNMENT_RIGHT:
			offset = rect.width() - textWidth;
			break;
		case SCI_TEXT16_ALIGNMENT_CENTER:
			offset = (rect.width() - textWidth) / 2;
			break;
		case SCI_TEXT16_ALIGNMENT_LEFT:
			offset = 0;
			break;

		default:
			warning("Invalid alignment %d used in TextBox()", alignment);
		}
		_ports->moveTo(rect.left + offset, rect.top + hline);

		if (show) {
			Show(curTextLine, 0, charCount, fontId, previousPenColor);
		} else {
			Draw(curTextLine, 0, charCount, fontId, previousPenColor);
		}

		hline += textHeight;
		curTextLine = curTextPos;
	}
	SetFont(previousFontId);
	_ports->penColor(previousPenColor);

	if (doubleByteMode) {
		// Kanji is written by pc98 rom to screen directly. Because of
		// GetLongest() behavior (not cutting off the last char, that causes a
		// new line), results in the script thinking that the text would need
		// less space. The coordinate adjustment in fontsjis.cpp handles the
		// incorrect centering because of that and this code actually shows all
		// of the chars - if we don't do this, the scripts will only show most
		// of the chars, but the last few pixels won't get shown most of the
		// time.
		Common::Rect kanjiRect = rect;
		_ports->offsetRect(kanjiRect);
		kanjiRect.left &= 0xFFC;
		kanjiRect.right = kanjiRect.left + maxTextWidth;
		kanjiRect.bottom = kanjiRect.top + hline;
		kanjiRect.left *= 2; kanjiRect.right *= 2;
		kanjiRect.top *= 2; kanjiRect.bottom *= 2;
		_screen->copyDisplayRectToScreen(kanjiRect);
	}
}
Esempio n. 6
0
BOOL CDisasm::DlgProc(UINT message, WPARAM wParam, LPARAM lParam)
{
	//if (!m_hDlg) return FALSE;
	switch(message)
	{
	case WM_INITDIALOG:
		{
			return TRUE;
		}
		break;

	case WM_TIMER:
		{
			int iPage = TabCtrl_GetCurSel (GetDlgItem(m_hDlg, IDC_LEFTTABS));
			ShowWindow(GetDlgItem(m_hDlg, IDC_FUNCTIONLIST), iPage?SW_NORMAL:SW_HIDE);
			ShowWindow(GetDlgItem(m_hDlg, IDC_REGLIST),      iPage?SW_HIDE:SW_NORMAL);
		}
		break;

	case WM_NOTIFY:
		{
			HWND tabs = GetDlgItem(m_hDlg, IDC_LEFTTABS);
			NMHDR* pNotifyMessage = NULL;
			pNotifyMessage = (LPNMHDR)lParam; 		
			if (pNotifyMessage->hwndFrom == tabs)
			{
				int iPage = TabCtrl_GetCurSel (tabs);
				ShowWindow(GetDlgItem(m_hDlg, IDC_FUNCTIONLIST), iPage?SW_NORMAL:SW_HIDE);
				ShowWindow(GetDlgItem(m_hDlg, IDC_REGLIST),      iPage?SW_HIDE:SW_NORMAL);
			}
			break;
		}

	case WM_COMMAND:
		{
			CtrlDisAsmView *ptr = CtrlDisAsmView::getFrom(GetDlgItem(m_hDlg,IDC_DISASMVIEW));
			CtrlRegisterList *reglist = CtrlRegisterList::getFrom(GetDlgItem(m_hDlg,IDC_REGLIST));
			switch(LOWORD(wParam))
			{
			case IDC_SHOWVFPU:
				vfpudlg->Show(true);
				break;

			case IDC_FUNCTIONLIST: 
        switch (HIWORD(wParam)) 
        { 
				  case CBN_DBLCLK:
          case CBN_SELCHANGE: 
					{
						HWND lb = GetDlgItem(m_hDlg,LOWORD(wParam));
						int n = ListBox_GetCurSel(lb);
						if (n!=-1)
						{
							unsigned int addr = (unsigned int)ListBox_GetItemData(lb,n);
							ptr->gotoAddr(addr);
						}
					}
					break;
				};
				break;

			case IDC_GOTOINT:
        switch (HIWORD(wParam)) 
        { 
        case LBN_SELCHANGE: 
					{
						HWND lb =GetDlgItem(m_hDlg,LOWORD(wParam));
						int n = ComboBox_GetCurSel(lb);
						unsigned int addr = (unsigned int)ComboBox_GetItemData(lb,n);
						if (addr != 0xFFFFFFFF)
							ptr->gotoAddr(addr);
					}
					break;
				};
				break;

			case IDC_GO:
				{
					SetDebugMode(false);
					Core_EnableStepping(false);
					MainWindow::UpdateMenus();
				}
				break;

			case IDC_STEP:
				{
					Core_DoSingleStep();		
					Sleep(1);
					_dbg_update_();
					ptr->gotoPC();
					reglist->redraw();
					vfpudlg->Update();
				}
				break;

			case IDC_STEPOVER:
				{
					SetDebugMode(false);
					CBreakPoints::AddBreakPoint(cpu->GetPC()+cpu->getInstructionSize(0),true);
					_dbg_update_();
					Core_EnableStepping(false);	
					MainWindow::UpdateMenus();
					Sleep(1);
					ptr->gotoPC();
					reglist->redraw();
				}
				break;
				
			case IDC_STOP:
				{				
					SetDebugMode(true);
					Core_EnableStepping(true);
					_dbg_update_();
					MainWindow::UpdateMenus();
					UpdateDialog();
					Sleep(1); //let cpu catch up
					ptr->gotoPC();
					reglist->redraw();
					vfpudlg->Update();
				}
				break;

			case IDC_SKIP:
				{
					cpu->SetPC(cpu->GetPC() + cpu->getInstructionSize(0));
					Sleep(1);
					ptr->gotoPC();
					UpdateDialog();
				}
				break;

			case IDC_ADDRESS:
				{
					if (HIWORD(wParam) == EN_CHANGE ) 
					{
						char szBuffer[32];
						GetWindowText ((HWND)lParam, szBuffer, 32);
						ptr->gotoAddr(parseHex(szBuffer));
						UpdateDialog();
					}
				}
				break;

			case IDC_UPDATECALLSTACK:
				{
					HWND hDlg = m_hDlg;
					HWND list = GetDlgItem(hDlg,IDC_CALLSTACK);
					ComboBox_ResetContent(list);
					
          u32 pc = currentMIPS->pc;
          u32 ra = currentMIPS->r[MIPS_REG_RA];
					DWORD addr = Memory::ReadUnchecked_U32(pc);
					int count=1;
					ComboBox_SetItemData(list,ComboBox_AddString(list,symbolMap.GetDescription(pc)),pc);
					if (symbolMap.GetDescription(pc) != symbolMap.GetDescription(ra))
					{
						ComboBox_SetItemData(list,ComboBox_AddString(list,symbolMap.GetDescription(ra)),ra);
						count++;
					}
					//walk the stack chain
					while (addr != 0xFFFFFFFF && addr!=0 && count++<20)
					{
						DWORD fun = Memory::ReadUnchecked_U32(addr+4);
						char *str = symbolMap.GetDescription(fun);
						if (strlen(str)==0)
							str = "(unknown)";
						ComboBox_SetItemData(list, ComboBox_AddString(list,str), fun);
						addr = Memory::ReadUnchecked_U32(addr);
					}
					ComboBox_SetCurSel(list,0);
				}
				break;

			case IDC_GOTOPC:
				{
					ptr->gotoPC();
					UpdateDialog();
				}
				break;
			case IDC_GOTOLR:
				{
					ptr->gotoAddr(cpu->GetLR());
				}
				break;

			case IDC_BACKWARDLINKS:
				{
					HWND box = GetDlgItem(m_hDlg, IDC_FUNCTIONLIST); 
					int funcnum = symbolMap.GetSymbolNum(ListBox_GetItemData(box,ListBox_GetCurSel(box)));
					if (funcnum!=-1)
						symbolMap.FillListBoxBLinks(box,funcnum);
					break;
				}

			case IDC_ALLFUNCTIONS:
				{
					symbolMap.FillSymbolListBox(GetDlgItem(m_hDlg, IDC_FUNCTIONLIST),ST_FUNCTION);
					break;
				}
			default:
				return FALSE;
			}
			return TRUE;
		}

	case WM_USER+1:
		NotifyMapLoaded();
		break;

	case WM_SIZE:
		{
			HWND disasm = GetDlgItem(m_hDlg, IDC_DISASMVIEW);
			HWND funclist = GetDlgItem(m_hDlg, IDC_FUNCTIONLIST);
			HWND regList = GetDlgItem(m_hDlg, IDC_REGLIST);
			int wf = regRect.right-regRect.left;
			int top = 138;
			MoveWindow(regList,8,top,wf,HIWORD(lParam)-top-8,TRUE);
			MoveWindow(funclist,8,top,wf,HIWORD(lParam)-top-8,TRUE);
			int w = LOWORD(lParam)-wf;
			top = 25;
			MoveWindow(disasm,wf+15,top, w-20,HIWORD(lParam)-top-8,TRUE);
			return TRUE;
		}

	case WM_GETMINMAXINFO:
		{
			MINMAXINFO *m = (MINMAXINFO *)lParam;
			m->ptMinTrackSize.x=minRect.right-minRect.left;
			//m->ptMaxTrackSize.x=m->ptMinTrackSize.x;
			m->ptMinTrackSize.y=minRect.bottom-minRect.top;
		}
		return TRUE;
	case WM_CLOSE:
		Show(false);
		return TRUE;
	}
	return FALSE;
}
Esempio n. 7
0
/*
	メインダイアログ用 WM_INITDIALOG 処理ルーチン
*/
BOOL TInstDlg::EvCreate(LPARAM lParam)
{
	char	title[256], title2[256];
	GetWindowText(title, sizeof(title));
	::wsprintf(title2, "%s ver%s", title, GetVersionStr());
	SetWindowText(title2);

	GetWindowRect(&rect);
	int		cx = ::GetSystemMetrics(SM_CXFULLSCREEN), cy = ::GetSystemMetrics(SM_CYFULLSCREEN);
	int		xsize = rect.right - rect.left, ysize = rect.bottom - rect.top;

	::SetClassLong(hWnd, GCL_HICON, (LONG)::LoadIcon(TApp::GetInstance(), (LPCSTR)SETUP_ICON));
	MoveWindow((cx - xsize)/2, (cy - ysize)/2, xsize, ysize, TRUE);
	Show();

	if (IsWinVista() && !::IsUserAnAdmin() && TIsEnableUAC()) {
		HWND	hRunas = GetDlgItem(RUNAS_BUTTON);
		::SetWindowLong(hRunas, GWL_STYLE, ::GetWindowLong(hRunas, GWL_STYLE)|WS_VISIBLE);
		::SendMessage(hRunas, BCM_SETSHIELD, 0, 1);
	}

// 現在ディレクトリ設定
	char	buf[MAX_PATH_U8], setupDir[MAX_PATH_U8];
#ifdef _WIN64
	char	x86dir[MAX_PATH_U8] = "";
#endif

// Program Filesのパス取り出し
	TRegistry	reg(HKEY_LOCAL_MACHINE);
	if (reg.OpenKey(REGSTR_PATH_SETUP)) {
		if (reg.GetStr(REGSTR_PROGRAMFILES, buf, sizeof(buf))) {
			MakePath(setupDir, buf, IPMSG_STR);
		}
#ifdef _WIN64
		if (reg.GetStr(REGSTR_PROGRAMFILESX86, buf, sizeof(buf)))
			MakePath(x86dir, buf, IPMSG_STR);
#endif
		reg.CloseKey();
	}

// 既にセットアップされている場合は、セットアップディレクトリを読み出す
	if (reg.OpenKey(REGSTR_PATH_APPPATHS)) {
		if (reg.OpenKey(IPMSG_EXENAME)) {
			if (reg.GetStr(REGSTR_PATH, buf, sizeof(buf))) {
#ifdef _WIN64
				if (strcmp(buf, x86dir))
#endif
				strcpy(setupDir, buf);
			}
			reg.CloseKey();
		}
		reg.CloseKey();
	}

	SetDlgItemTextU8(FILE_EDIT, setupDir);
	CheckDlgButton(STARTUP_CHECK, 1);
	CheckDlgButton(PROGRAM_CHECK, 1);
	CheckDlgButton(DESKTOP_CHECK, 1);
	CheckDlgButton(EXTRACT_CHECK, 0);

	char	*p = strstr(GetCommandLine(), "runas=");
	if (p) {
		runasWnd = (HWND)strtoul(p+6, 0, 16);
		if (!runasWnd || !IsWindow(runasWnd)) PostQuitMessage(0);
		if ((p = strstr(p, ",imm="))) runasImm = atoi(p+5);

		CheckDlgButton(EXTRACT_CHECK, ::IsDlgButtonChecked(runasWnd, EXTRACT_CHECK));
		CheckDlgButton(STARTUP_CHECK, ::IsDlgButtonChecked(runasWnd, STARTUP_CHECK));
		CheckDlgButton(PROGRAM_CHECK, ::IsDlgButtonChecked(runasWnd, PROGRAM_CHECK));
		CheckDlgButton(DESKTOP_CHECK, ::IsDlgButtonChecked(runasWnd, DESKTOP_CHECK));

		WCHAR	wbuf[MAX_PATH] = L"";
		::SendDlgItemMessageW(runasWnd, FILE_EDIT, WM_GETTEXT, MAX_PATH, (LPARAM)wbuf);
		SetDlgItemTextU8(FILE_EDIT, WtoU8s(wbuf));

		::SendMessage(runasWnd, WM_IPMSG_HIDE, 0, 0);
		if (runasImm) {
			PostMessage(WM_IPMSG_INSTALL, 0, 0);
		}
	}

	return	TRUE;
}
Esempio n. 8
0
void cPanelMinimap::OnClose(wxCloseEvent& event)
{
	Show(false);
}
Esempio n. 9
0
int Win::DoModal()
{
	WinID lastParentFC = parent ? parent->lastFocusChild : 0; 
	bool visibled = IsVisible();
	bool enabled = IsEnabled();
	try {
		if (!visibled) Show();
		if (!enabled) Enable(true);

		if (parent && type != WT_POPUP) parent->RecalcLayouts();

		AppBlock(GetID());
		UnblockTree(GetID());

		ModalStruct modalStruct;
		modal = &modalStruct;

		MSG msg;
		
		while (!modalStruct.end) 
		{
			wth_DoEvents();
			if (modalStruct.end) break;

			if (!PeekMessage(&msg, NULL, 0, 0,PM_NOREMOVE))
			{
				unsigned waitTime = RunTimers();
				if (waitTime > 5000) waitTime = 5000;
				if (modalStruct.end) break;

				HANDLE thEvent = wthInternalEvent.SignalFD();
				DWORD res = MsgWaitForMultipleObjects(1,&thEvent,FALSE, waitTime, QS_ALLINPUT);

				if (res == WAIT_TIMEOUT) CheckMousePosition();

				continue;
			}

			if (!GetMessage(&msg, NULL, 0, 0)) 
				break;

			DispatchMessage(&msg);
		}

		modal = 0;
		AppUnblock(GetID());
		if (!visibled) Hide();

///
		if (type == WT_POPUP || type == WT_CHILD && parent) 
		{
			Win *w = GetWinByID(lastParentFC);
			if (w) w->SetFocus();
		}

		return modalStruct.id;
	} catch (...) {
		modal = 0;
		AppUnblock(GetID());
		if (!visibled) Hide(); 
		throw;
	}
}
VectorImage::Draw(gfxContext* aContext,
                  const nsIntSize& aSize,
                  const ImageRegion& aRegion,
                  uint32_t aWhichFrame,
                  GraphicsFilter aFilter,
                  const Maybe<SVGImageContext>& aSVGContext,
                  uint32_t aFlags)
{
  if (aWhichFrame > FRAME_MAX_VALUE) {
    return DrawResult::BAD_ARGS;
  }

  if (!aContext) {
    return DrawResult::BAD_ARGS;
  }

  if (mError) {
    return DrawResult::BAD_IMAGE;
  }

  if (!mIsFullyLoaded) {
    return DrawResult::NOT_READY;
  }

  if (mIsDrawing) {
    NS_WARNING("Refusing to make re-entrant call to VectorImage::Draw");
    return DrawResult::TEMPORARY_ERROR;
  }

  if (mAnimationConsumers == 0 && mProgressTracker) {
    mProgressTracker->OnUnlockedDraw();
  }

  AutoRestore<bool> autoRestoreIsDrawing(mIsDrawing);
  mIsDrawing = true;

  float animTime = (aWhichFrame == FRAME_FIRST) ? 0.0f
                                                : mSVGDocumentWrapper->GetCurrentTime();
  AutoSVGRenderingState autoSVGState(aSVGContext, animTime,
                                     mSVGDocumentWrapper->GetRootSVGElem());

  // Pack up the drawing parameters.
  SVGDrawingParameters params(aContext, aSize, aRegion, aFilter,
                              aSVGContext, animTime, aFlags);

  if (aFlags & FLAG_BYPASS_SURFACE_CACHE) {
    CreateSurfaceAndShow(params);
    return DrawResult::SUCCESS;
  }

  DrawableFrameRef frameRef =
    SurfaceCache::Lookup(ImageKey(this),
                         VectorSurfaceKey(params.size,
                                          params.svgContext,
                                          params.animationTime));

  // Draw.
  if (frameRef) {
    RefPtr<SourceSurface> surface = frameRef->GetSurface();
    if (surface) {
      nsRefPtr<gfxDrawable> svgDrawable =
        new gfxSurfaceDrawable(surface, ThebesIntSize(frameRef->GetSize()));
      Show(svgDrawable, params);
      return DrawResult::SUCCESS;
    }

    // We lost our surface due to some catastrophic event.
    RecoverFromLossOfSurfaces();
  }

  CreateSurfaceAndShow(params);

  return DrawResult::SUCCESS;
}
void
VectorImage::CreateSurfaceAndShow(const SVGDrawingParameters& aParams)
{
  mSVGDocumentWrapper->UpdateViewportBounds(aParams.viewportSize);
  mSVGDocumentWrapper->FlushImageTransformInvalidation();

  nsRefPtr<gfxDrawingCallback> cb =
    new SVGDrawingCallback(mSVGDocumentWrapper,
                           nsIntRect(nsIntPoint(0, 0), aParams.viewportSize),
                           aParams.size,
                           aParams.flags);

  nsRefPtr<gfxDrawable> svgDrawable =
    new gfxCallbackDrawable(cb, ThebesIntSize(aParams.size));

  // We take an early exit without using the surface cache if too large,
  // because for vector images this can cause bad perf issues if large sizes
  // are scaled repeatedly (a rather common scenario) that can quickly exhaust
  // the cache.
  // Similar to max image size calculations, this has a max cap and size check.
  // max cap = 8000 (pixels); size check = 5% of cache
  int32_t maxDimension = 8000;
  int32_t maxCacheElemSize = (gfxPrefs::ImageMemSurfaceCacheMaxSizeKB() * 1024) / 20;
  
  bool bypassCache = bool(aParams.flags & FLAG_BYPASS_SURFACE_CACHE) ||
                     // Refuse to cache animated images:
                     // XXX(seth): We may remove this restriction in bug 922893.
                     mHaveAnimations ||
                     // The image is too big to fit in the cache:
                     !SurfaceCache::CanHold(aParams.size) ||
                     // Image x or y is larger than our cache cap:
                     aParams.size.width > maxDimension ||
                     aParams.size.height > maxDimension;
  if (!bypassCache) {
    // This is separated out to make sure width and height are sane at this point
    // and the result can't overflow. Note: keep maxDimension low enough so that
    // (maxDimension)^2 x 4 < INT32_MAX.
    // Assuming surface size for any rendered vector image is RGBA, so 4Bpp.
    bypassCache = (aParams.size.width * aParams.size.height * 4) > maxCacheElemSize;
  }

  if (bypassCache)
    return Show(svgDrawable, aParams);

  // Try to create an imgFrame, initializing the surface it contains by drawing
  // our gfxDrawable into it. (We use FILTER_NEAREST since we never scale here.)
  nsRefPtr<imgFrame> frame = new imgFrame;
  nsresult rv =
    frame->InitWithDrawable(svgDrawable, ThebesIntSize(aParams.size),
                            SurfaceFormat::B8G8R8A8,
                            GraphicsFilter::FILTER_NEAREST, aParams.flags);

  // If we couldn't create the frame, it was probably because it would end
  // up way too big. Generally it also wouldn't fit in the cache, but the prefs
  // could be set such that the cache isn't the limiting factor.
  if (NS_FAILED(rv))
    return Show(svgDrawable, aParams);

  // Take a strong reference to the frame's surface and make sure it hasn't
  // already been purged by the operating system.
  RefPtr<SourceSurface> surface = frame->GetSurface();
  if (!surface)
    return Show(svgDrawable, aParams);

  // Attempt to cache the frame.
  SurfaceCache::Insert(frame, ImageKey(this),
                       VectorSurfaceKey(aParams.size,
                                        aParams.svgContext,
                                        aParams.animationTime),
                       Lifetime::Transient);

  // Draw.
  nsRefPtr<gfxDrawable> drawable =
    new gfxSurfaceDrawable(surface, ThebesIntSize(aParams.size));
  Show(drawable, aParams);
}
Esempio n. 12
0
appFrame::appFrame( wxFrame *frame,
					const wxChar *title,
					int x, int y, int w, int h)
                 : wxFrame( frame, -1, title, wxPoint( x, y ), wxSize( w, h ) )
{
	// Set the default node address	
	// Note that MSB is in byte 0 beacuse it should
	// be copied as the first byte in the datagram 
	m_nodeAddr[ 15 ] = 1; // User value LSB
	m_nodeAddr[ 14 ] = 0; // User Value MSB
	m_nodeAddr[ 13 ] = 0; // Ethernet MAC LSB
	m_nodeAddr[ 12 ] = 0;
	m_nodeAddr[ 11 ] = 0;
	m_nodeAddr[ 10 ] = 0;
	m_nodeAddr[  9 ] = 0;
	m_nodeAddr[  8 ] = 0; // Ethernet MAC MSB
	m_nodeAddr[  7 ] = 0xfe;
	m_nodeAddr[  6 ] = 0xff;
	m_nodeAddr[  5 ] = 0xff;
	m_nodeAddr[  4 ] = 0xff;
	m_nodeAddr[  3 ] = 0xff;
	m_nodeAddr[  2 ] = 0xff;
	m_nodeAddr[  1 ] = 0xff;
	m_nodeAddr[  0 ] = 0xff;

	// Default group
	m_zone = 0;

	// Set address from MAC address
	getMacAddress();
	
	m_secondCounter = 0;

	// create the status line
	const int widths[] = { -1, 60, 60 };
	CreateStatusBar( 3 );
	SetStatusWidths( 3, widths );
	wxLogStatus( this, wxT("Dimmer") );
	
	///////////////////////////////////////////////////////////////////////////
	//            Persistent storage first time initialization
	///////////////////////////////////////////////////////////////////////////

    // Make a menubar
    // --------------

    // file submenu
    wxMenu *menuFile = new wxMenu;
    menuFile->Append( MenuAbout, wxT("&About...\tF1") );
    menuFile->AppendSeparator();
    menuFile->Append( MenuQuit, wxT("E&xit\tAlt-X") );

    // tools submenu
    //wxMenu *menuTools = new wxMenu;
    //menuTools->Append( MenuTest, wxT("Testa OLE System\tCtrl-M") );

	// options submenu
    wxMenu *menuOptions = new wxMenu;
	menuOptions->Append( MenuOptions, wxT("&General Settings...\tF10") );

    // put it all together
    wxMenuBar *menu_bar = new wxMenuBar;
    menu_bar->Append( menuFile, wxT("&File") );
    menu_bar->Append( menuOptions, wxT("&Settings") );
    SetMenuBar( menu_bar );

    // make a panel with some controls
    m_panel = new wxPanel( this, -1, wxPoint( 0, 0 ), wxSize(400, 200), wxTAB_TRAVERSAL);

    // create buttons for moving the items around
    m_buttonDown = new wxButton( m_panel, BtnDown, wxT("<<"), wxPoint( 420, 60  ) );
	m_buttonUp = new wxButton( m_panel, BtnUp, wxT(">>"), wxPoint( 420, 90  ) );
    
	m_buttonOff = new wxButton( m_panel, BtnOff, wxT("O&ff"), wxPoint( 420, 120 ) );
	m_buttonOn = new wxButton( m_panel, BtnOn, wxT("&On"), wxPoint( 420, 120 ) );	

	// Sizer for the listbox
    wxBoxSizer *mainsizer = new wxBoxSizer( wxVERTICAL );
	
	// Sizer for the buttons
    wxBoxSizer *bottomsizer1 = new wxBoxSizer( wxHORIZONTAL );

    bottomsizer1->Add( m_buttonDown, 0, wxALL, 10 );
	bottomsizer1->Add( m_buttonUp, 0, wxALL, 10 );

	wxBoxSizer *bottomsizer2 = new wxBoxSizer( wxHORIZONTAL );

	bottomsizer2->Add( m_buttonOff, 0, wxALL, 10 );
	bottomsizer2->Add( m_buttonOn, 0, wxALL, 10 );

    mainsizer->Add( bottomsizer1, 0, wxCENTER );
	mainsizer->Add( bottomsizer2, 0, wxCENTER );

    // tell frame to make use of sizer (or constraints, if any)
    m_panel->SetAutoLayout( TRUE );
    m_panel->SetSizer( mainsizer );

    // don't allow frame to get smaller than what the sizers tell ye
    mainsizer->SetSizeHints( this );

	if ( !m_vscpif.doCmdOpen() ) {
		wxMessageBox( _T("Failed to contact the VSCP daemon") );
		Close( TRUE );
	}

	// Initialize timeevents
	m_timer.SetOwner( this, RefreshTimer );
	m_timer.Start( 200 );   // set timer interval

    Show( TRUE );

}
Esempio n. 13
0
BOOL CProgressWnd::Create(CWnd* pParent, LPCTSTR pszTitle, BOOL bSmooth /* = FALSE */)
{
    BOOL bSuccess;

	m_strTitle = pszTitle;
    // Register window class
    CString csClassName = AfxRegisterWndClass(CS_OWNDC|CS_HREDRAW|CS_VREDRAW,
                                              ::LoadCursor(NULL, IDC_APPSTARTING),
                                              CBrush(::GetSysColor(COLOR_BTNFACE)));

    // Get the system window message font for use in the cancel button and text area
    NONCLIENTMETRICS ncm;
    ncm.cbSize = sizeof(NONCLIENTMETRICS);
    VERIFY(SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0));
    m_font.CreateFontIndirect(&(ncm.lfMessageFont)); 

    // If no parent supplied then try and get a pointer to it anyway
    if (!pParent)
        pParent = AfxGetMainWnd();

    // Create popup window
    //bSuccess = CreateEx(WS_EX_DLGMODALFRAME|WS_EX_TOPMOST, // Extended style
	bSuccess = CreateEx(WS_EX_DLGMODALFRAME,
                        csClassName,                       // Classname
                        pszTitle,                          // Title
                        WS_POPUP|WS_BORDER|WS_CAPTION,     // style
                        0,0,                               // position - updated soon.
                        390,130,                           // Size - updated soon
                        pParent->GetSafeHwnd(),            // handle to parent
                        0,                                 // No menu
                        NULL);    
    if (!bSuccess) return FALSE;

    // Now create the controls
    CRect TempRect(0,0,10,10);

    bSuccess = m_Text.Create(_T(""), WS_CHILD|WS_VISIBLE|SS_NOPREFIX|SS_LEFTNOWORDWRAP,
                             TempRect, this, IDC_TEXT);
    if (!bSuccess) return FALSE;

    DWORD dwProgressStyle = WS_CHILD|WS_VISIBLE;
#ifdef PBS_SMOOTH    
    if (bSmooth)
       dwProgressStyle |= PBS_SMOOTH;
#endif
    bSuccess = m_wndProgress.Create(dwProgressStyle,TempRect, this, IDC_PROGRESS);
    if (!bSuccess) return FALSE;

    bSuccess = m_CancelButton.Create(m_strCancelLabel, 
                                   WS_CHILD|WS_VISIBLE|WS_TABSTOP| BS_PUSHBUTTON, 
                                     TempRect, this, IDC_CANCEL);
    if (!bSuccess) return FALSE;

    m_CancelButton.SetFont(&m_font, TRUE);
    m_Text.SetFont(&m_font, TRUE);

    // Resize the whole thing according to the number of text lines, desired window
    // width and current font.
    SetWindowSize(m_nNumTextLines, 390);

    // Center and show window
    if (m_bPersistantPosition)
        GetPreviousSettings();
    else
        CenterWindow();

    Show();

    return TRUE;
}
Esempio n. 14
0
void Stack::ShowAll()
{
	if (!m_widgets.empty())
		m_widgets.top()->ShowAll();
	Show();
}
Esempio n. 15
0
void ToolBarMiniFrame::DoShow(bool visible)
{
   Show(visible);
}
Esempio n. 16
0
bool CWinSystemEGL::Restore()
{
  Show(true);
  return false;
}
Esempio n. 17
0
void ToolBarFullFrame::DoShow(bool visible)
{
   Show(visible);
}
Esempio n. 18
0
bool wxGenericProgressDialog::Create( const wxString& title,
                                      const wxString& message,
                                      int maximum,
                                      wxWindow *parent,
                                      int style )
{
    SetTopParent(parent);

    m_pdStyle = style;

    if (!wxDialog::Create(m_parentTop, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, GetWindowStyle()))
        return false;

    SetMaximum(maximum);

    // We need a running event loop in order to update the dialog and be able
    // to process clicks on its buttons, so ensure that there is one running
    // even if this means we have to start it ourselves (this happens most
    // commonly during the program initialization, e.g. for the progress
    // dialogs shown from overridden wxApp::OnInit()).
    EnsureActiveEventLoopExists();

#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
    // we have to remove the "Close" button from the title bar then as it is
    // confusing to have it - it doesn't work anyhow
    //
    // FIXME: should probably have a (extended?) window style for this
    if ( !HasPDFlag(wxPD_CAN_ABORT) )
    {
        EnableCloseButton(false);
    }
#endif // wxMSW

    m_state = HasPDFlag(wxPD_CAN_ABORT) ? Continue : Uncancelable;

    // top-level sizerTop
    wxSizer * const sizerTop = new wxBoxSizer(wxVERTICAL);

    m_msg = new wxStaticText(this, wxID_ANY, message);
    sizerTop->Add(m_msg, 0, wxLEFT | wxRIGHT | wxTOP, 2*LAYOUT_MARGIN);

    int gauge_style = wxGA_HORIZONTAL;
    if ( style & wxPD_SMOOTH )
        gauge_style |= wxGA_SMOOTH;
    gauge_style |= wxGA_PROGRESS;

#ifdef __WXMSW__
    maximum /= m_factor;
#endif

    m_gauge = new wxGauge
                  (
                    this,
                    wxID_ANY,
                    maximum,
                    wxDefaultPosition,
                    // make the progress bar sufficiently long
                    wxSize(wxMin(wxGetClientDisplayRect().width/3, 300), -1),
                    gauge_style
                  );

    sizerTop->Add(m_gauge, 0, wxLEFT | wxRIGHT | wxTOP | wxEXPAND, 2*LAYOUT_MARGIN);
    m_gauge->SetValue(0);

    // create the estimated/remaining/total time zones if requested
    m_elapsed =
    m_estimated =
    m_remaining = NULL;

    // also count how many labels we really have
    size_t nTimeLabels = 0;

    wxSizer * const sizerLabels = new wxFlexGridSizer(2);

    if ( style & wxPD_ELAPSED_TIME )
    {
        nTimeLabels++;

        m_elapsed = CreateLabel(GetElapsedLabel(), sizerLabels);
    }

    if ( style & wxPD_ESTIMATED_TIME )
    {
        nTimeLabels++;

        m_estimated = CreateLabel(GetEstimatedLabel(), sizerLabels);
    }

    if ( style & wxPD_REMAINING_TIME )
    {
        nTimeLabels++;

        m_remaining = CreateLabel(GetRemainingLabel(), sizerLabels);
    }
    sizerTop->Add(sizerLabels, 0, wxALIGN_CENTER_HORIZONTAL | wxTOP, LAYOUT_MARGIN);

    wxStdDialogButtonSizer *buttonSizer = wxDialog::CreateStdDialogButtonSizer(0);

    const int borderFlags = wxALL;

    wxSizerFlags sizerFlags
        = wxSizerFlags().Border(borderFlags, LAYOUT_MARGIN);

    if ( HasPDFlag(wxPD_CAN_SKIP) )
    {
        m_btnSkip = new wxButton(this, wxID_SKIP, _("&Skip"));

        buttonSizer->SetNegativeButton(m_btnSkip);
    }

    if ( HasPDFlag(wxPD_CAN_ABORT) )
    {
        m_btnAbort = new wxButton(this, wxID_CANCEL);

        buttonSizer->SetCancelButton(m_btnAbort);
    }

    if ( !HasPDFlag(wxPD_CAN_SKIP | wxPD_CAN_ABORT) )
        buttonSizer->AddSpacer(LAYOUT_MARGIN);

    buttonSizer->Realize();

    sizerTop->Add(buttonSizer, sizerFlags.Expand());

    SetSizerAndFit(sizerTop);

    Centre(wxCENTER_FRAME | wxBOTH);

    DisableOtherWindows();

    Show();
    Enable();

    // this one can be initialized even if the others are unknown for now
    //
    // NB: do it after calling Layout() to keep the labels correctly aligned
    if ( m_elapsed )
    {
        SetTimeLabel(0, m_elapsed);
    }

    Update();
    return true;
}
Esempio n. 19
0
BOOL TInstDlg::Install(void)
{
	char	buf[MAX_PATH_U8], setupDir[MAX_PATH_U8], setupPath[MAX_PATH_U8];
	char	installPath[MAX_PATH_U8];
	BOOL	extract_only = IsDlgButtonChecked(EXTRACT_CHECK);

// 現在、起動中の ipmsg を終了
	int		st = extract_only ? 0 : TerminateIPMsg();
	if (st == 1) return	FALSE;

// インストールパス設定
	GetDlgItemTextU8(FILE_EDIT, setupDir, sizeof(setupDir));

	if (IsWinVista() && !::IsUserAnAdmin() && TIsEnableUAC()
			&& TIsVirtualizedDirW(U8toWs(setupDir))) {
		if (MessageBox(GetLoadStr(IDS_REQUIREADMIN), INSTALL_STR,
				MB_OKCANCEL|MB_ICONINFORMATION) != IDOK) return	FALSE;
		return	RunAsAdmin(hWnd, TRUE);
	}

	CreateDirectoryU8(setupDir, NULL);
	DWORD	attr = GetFileAttributesU8(setupDir);
	if (attr == 0xffffffff || (attr & FILE_ATTRIBUTE_DIRECTORY) == 0)
		return	MessageBox(GetLoadStr(IDS_NOTCREATEDIR), INSTALL_STR), FALSE;
	MakePath(setupPath, setupDir, IPMSG_EXENAME);

	if (st == 2) {
		MessageBox(GetLoadStr(IDS_CANTTERMINATE), INSTALL_STR);
		return	FALSE;
	}
	if (!runasImm &&
		MessageBox(GetLoadStr(IDS_START), INSTALL_STR, MB_OKCANCEL|MB_ICONINFORMATION) != IDOK) {
		return	FALSE;
	}
	runasImm = FALSE;

// ファイル生成
	for (int i=0; SetupFiles[i]; i++) {
		MakePath(installPath, setupDir, SetupFiles[i]);
		CreateStatus cs = CreateFileBySelf(installPath, SetupFiles[i]);
		if (cs == CS_BROKEN) {
			MessageBox(GetLoadStr(IDS_BROKENARCHIVE), INSTALL_STR);
			return	FALSE;
		}
		else if (cs == CS_ACCESS) {
			const char *msg = Fmt("%s\r\n%s", GetLoadStrU8(IDS_NOTCREATEFILE), installPath);
			MessageBoxU8(msg, INSTALL_STR);
			return	FALSE;
		}
	}

// 展開のみ
	if (extract_only) {
		ShellExecuteW(NULL, NULL, U8toWs(setupDir), 0, 0, SW_SHOW);
		return TRUE;
	}

// スタートアップ&デスクトップに登録
	TRegistry	reg(HKEY_CURRENT_USER);
	if (reg.OpenKey(REGSTR_SHELLFOLDERS)) {
		char	*regStr[] = { REGSTR_STARTUP, REGSTR_PROGRAMS, REGSTR_DESKTOP, NULL };
		BOOL	resId[]   = { STARTUP_CHECK,  PROGRAM_CHECK,   DESKTOP_CHECK,  NULL };

		for (int i=0; regStr[i]; i++) {
			if (reg.GetStr(regStr[i], buf, sizeof(buf))) {
				if (i != 0 || !RemoveSameLink(buf, buf))
					::wsprintf(buf + strlen(buf), "\\%s", IPMSG_SHORTCUT_NAME);
				if (IsDlgButtonChecked(resId[i]))
					SymLink(setupPath, buf);
				else
					DeleteLink(buf);
			}
		}
		reg.CloseKey();
	}

// レジストリにアプリケーション情報を登録
	reg.ChangeTopKey(HKEY_LOCAL_MACHINE);
	if (reg.OpenKey(REGSTR_PATH_APPPATHS)) {
		if (reg.CreateKey(IPMSG_EXENAME)) {
			reg.SetStr(NULL, setupPath);
			reg.SetStr(REGSTR_PATH, setupDir);
			reg.CloseKey();
		}
		reg.CloseKey();
	}

// レジストリにアンインストール情報を登録
	if (reg.OpenKey(REGSTR_PATH_UNINSTALL)) {
		if (reg.CreateKey(IPMSG_NAME)) {
			MakePath(buf, setupDir, SETUP_EXENAME);
			strcat(buf, " /r");
			reg.SetStr(REGSTR_VAL_UNINSTALLER_DISPLAYNAME, IPMSG_FULLNAME);
			reg.SetStr(REGSTR_VAL_UNINSTALLER_COMMANDLINE, buf);
			reg.CloseKey();
		}
		reg.CloseKey();
	}

// コピーしたアプリケーションを起動
	const char *msg = GetLoadStr(IDS_SETUPCOMPLETE);
	int			flg = MB_OKCANCEL|MB_ICONINFORMATION;

//	if (IsWinVista() && ::IsUserAnAdmin() && TIsEnableUAC()) {
//		msg = Fmt("%s%s", msg, GetLoadStr(IDS_COMPLETE_UACADD));
//		flg |= MB_DEFBUTTON2;
//	}
	TLaunchDlg	dlg(msg, this);
	if (dlg.Exec() == IDOK) {
		if (runasWnd) {
			Wstr	wbuf(setupDir);
			if (::SendDlgItemMessageW(runasWnd, FILE_EDIT, WM_SETTEXT, 0, (LPARAM)wbuf.Buf())) {
				::PostMessage(runasWnd, WM_IPMSG_QUIT, 1, 0);
				runasWnd = NULL;
			}
		}
		else {
			AppKick();
		}
	}
	else {
		HWND	hHelp = ShowHelpU8(0, setupDir, GetLoadStrU8(IDS_IPMSGHELP), "#history");
		if (hHelp) {
			Show(SW_HIDE);
			while (::IsWindow(hHelp)) {
				this->Sleep(100);
			}
		}
	}

	if (runasWnd) {
		::PostMessage(runasWnd, WM_IPMSG_QUIT, 0, 0);
		runasWnd = NULL;
	}

//	ShellExecuteU8(NULL, NULL, setupDir, 0, 0, SW_SHOW);
	::PostQuitMessage(0);
	return	TRUE;
}
Esempio n. 20
0
EULAWindow::EULAWindow()
	:
	BWindow(BRect(0, 0, 600, 450), B_TRANSLATE("README"),
		B_MODAL_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_NOT_ZOOMABLE
		| B_NOT_MINIMIZABLE | B_AUTO_UPDATE_SIZE_LIMITS)
{
	BString infoText;
	infoText << B_TRANSLATE(
		"Welcome to the Haiku Installer!\n\n");
	infoText << B_TRANSLATE(
		"IMPORTANT INFORMATION BEFORE INSTALLING HAIKU\n\n");
	infoText << B_TRANSLATE(
		"This is alpha-quality software! It means there is a high risk of "
		"losing important data. Make frequent backups! You have been "
		"warned.\n\n\n");
	infoText << B_TRANSLATE(
		"1)   If you are installing Haiku onto real hardware (not inside an "
		"emulator) it is recommended that you have already prepared a hard "
		"disk partition. The Installer and the DriveSetup tool offer to "
		"initialize existing partitions with the Haiku native file system, "
		"but the options to change the actual partition layout may not have "
		"been tested on a sufficiently great variety of computer "
		"configurations so we do not recommend using it.\n");
	infoText << B_TRANSLATE(
		"If you have not created a partition yet, simply reboot, create the "
		"partition using whatever tool you feel most comfortable with, and "
		"reboot into Haiku to continue with the installation. You could for "
		"example use the GParted Live-CD, it can also resize existing "
		"partitions to make room.\n\n\n");
	infoText << B_TRANSLATE(
		"2)   The Installer will make the Haiku partition itself bootable, "
		"but takes no steps to integrate Haiku into an existing boot menu. "
		"If you have GRUB already installed, you can add Haiku to its boot "
		"menu. Depending on what version of GRUB you use, this is done "
		"differently.\n\n\n");
	infoText << B_TRANSLATE(
		"2.1) GRUB (since os-prober v1.44)\n");
	infoText << B_TRANSLATE(
		"Starting with os-prober v1.44 (e.g. in Ubuntu 11.04 or later), Haiku "
		"should be recognized out of the box. To add Haiku to the GRUB menu, "
		"open a Terminal and enter:\n\n");
	infoText << B_TRANSLATE(
		"\tsudo update-grub\n\n\n");
	infoText << B_TRANSLATE(
		"2.2) GRUB 2\n");
	infoText << B_TRANSLATE(
		"If the os-prober approach doesn't work for you, GRUB 2 uses an extra "
		"configuration file to add custom entries to the boot menu. To add "
		"them to the top, you have to create/edit a file by launching your "
		"favorite editor from a Terminal like this:\n\n");
	infoText << B_TRANSLATE(
		"\tsudo <your favorite text editor> /etc/grub.d/40_custom\n\n");
	infoText << B_TRANSLATE(
		"GRUB's naming scheme for partitions is: (hdN,n)\n\n");
	infoText << B_TRANSLATE(
		"All hard disks start with \"hd\".\n");
	infoText << B_TRANSLATE(
		"\"N\" is the hard disk number, starting with \"0\".\n");
	infoText << B_TRANSLATE(
		"\"n\" is the partition number, which for GRUB 2 starts with \"1\"\n");
	infoText << B_TRANSLATE(
		"With GRUB 2 the first logical partition always has the number \"5\", "
		"regardless of the number of primary partitions.\n\n");
	infoText << B_TRANSLATE(
		"So below the heading that must not be edited, add something similar "
		"to these lines:\n\n");
	infoText << B_TRANSLATE(
		"\t# Haiku on /dev/sda7\n");
	infoText << B_TRANSLATE(
		"\tmenuentry \"Haiku Alpha\" {\n");
	infoText << B_TRANSLATE(
		"\t\tset root=(hd0,7)\n");
	infoText << B_TRANSLATE(
		"\t\tchainloader +1\n");
	infoText << B_TRANSLATE(
		"\t}\n\n");
	infoText << B_TRANSLATE(
		"Additionally you have to edit another file to actually display the "
		"boot menu:\n\n");
	infoText << B_TRANSLATE(
		"\tsudo <your favorite text editor> /etc/default/grub\n\n");
	infoText << B_TRANSLATE(
		"Here you have to comment out the line \"GRUB_HIDDEN_TIMEOUT=0\" by "
		"putting a \"#\" in front of it in order to actually display the "
		"boot menu.\n\n");
	infoText << B_TRANSLATE(
		"Finally, you have to update the boot menu by entering:\n\n");
	infoText << B_TRANSLATE(
		"\tsudo update-grub\n\n\n");
	infoText << B_TRANSLATE(
		"3)   When you successfully boot into Haiku for the first time, make "
		"sure to read our \"Welcome\" and \"Userguide\" documentation. There "
		"are links on the Desktop and in WebPositive's bookmarks.\n\n");
	infoText << B_TRANSLATE(
		"Have fun and thanks a lot for trying out Haiku! We hope you like it!");

	BTextView* textView = new BTextView("eula", be_plain_font, NULL, B_WILL_DRAW);
	textView->SetInsets(10, 10, 10, 10);
	textView->MakeEditable(false);
	textView->MakeSelectable(false);
	textView->SetText(infoText);

	BScrollView* scrollView = new BScrollView("eulaScroll",
		textView, B_WILL_DRAW, false, true);

	BButton* cancelButton = new BButton(B_TRANSLATE("Quit"),
		new BMessage(B_QUIT_REQUESTED));
	cancelButton->SetTarget(be_app);

	BButton* continueButton = new BButton(B_TRANSLATE("Continue"),
		new BMessage(kMsgAgree));
	continueButton->SetTarget(be_app);
	continueButton->MakeDefault(true);

	if (!be_roster->IsRunning(kTrackerSignature))
		SetWorkspaces(B_ALL_WORKSPACES);

	BLayoutBuilder::Group<>(this, B_VERTICAL, B_USE_DEFAULT_SPACING)
		.SetInsets(B_USE_WINDOW_SPACING)
		.Add(scrollView)
		.AddGroup(B_HORIZONTAL, B_USE_ITEM_SPACING)
			.AddGlue()
			.Add(cancelButton)
			.Add(continueButton);

	CenterOnScreen();
	Show();
}
Esempio n. 21
0
void GSFrame::CoreThread_OnResumed()
{
	m_timer_UpdateTitle.Start( TitleBarUpdateMs );
	if( !IsShown() ) Show();
}
Esempio n. 22
0
void
ShowImageWindow::MessageReceived(BMessage* message)
{
	if (message->WasDropped()) {
		uint32 type;
		int32 count;
		status_t status = message->GetInfo("refs", &type, &count);
		if (status == B_OK && type == B_REF_TYPE) {
			message->what = B_REFS_RECEIVED;
			be_app->PostMessage(message);
		}
	}

	switch (message->what) {
		case kMsgImageCacheImageLoaded:
		{
			fProgressWindow->Stop();

			BitmapOwner* bitmapOwner = NULL;
			message->FindPointer("bitmapOwner", (void**)&bitmapOwner);

			bool first = fImageView->Bitmap() == NULL;
			entry_ref ref;
			message->FindRef("ref", &ref);
			if (!first && ref != fNavigator.CurrentRef()) {
				// ignore older images
				if (bitmapOwner != NULL)
					bitmapOwner->ReleaseReference();
				break;
			}

			int32 page = message->FindInt32("page");
			int32 pageCount = message->FindInt32("pageCount");
			if (!first && page != fNavigator.CurrentPage()) {
				// ignore older pages
				if (bitmapOwner != NULL)
					bitmapOwner->ReleaseReference();
				break;
			}

			status_t status = fImageView->SetImage(message);
			if (status != B_OK) {
				if (bitmapOwner != NULL)
					bitmapOwner->ReleaseReference();

				_LoadError(ref);

				// quit if file could not be opened
				if (first)
					Quit();
				break;
			}

			fImageType = message->FindString("type");
			fNavigator.SetTo(ref, page, pageCount);

			fImageView->FitToBounds();
			if (first) {
				fImageView->MakeFocus(true);
					// to receive key messages
				Show();
			}
			_UpdateRatingMenu();
			// Set width and height attributes of the currently showed file.
			// This should only be a temporary solution.
			_SaveWidthAndHeight();
			break;
		}

		case kMsgImageCacheProgressUpdate:
		{
			entry_ref ref;
			if (message->FindRef("ref", &ref) == B_OK
				&& ref == fNavigator.CurrentRef()) {
				message->what = kMsgProgressUpdate;
				fProgressWindow->PostMessage(message);
			}
			break;
		}

		case MSG_MODIFIED:
			// If image has been modified due to a Cut or Paste
			fModified = true;
			break;

		case MSG_OUTPUT_TYPE:
			// User clicked Save As then choose an output format
			if (!fSavePanel)
				// If user doesn't already have a save panel open
				_SaveAs(message);
			break;

		case MSG_SAVE_PANEL:
			// User specified where to save the output image
			_SaveToFile(message);
			break;

		case B_CANCEL:
			delete fSavePanel;
			fSavePanel = NULL;
			break;

		case MSG_UPDATE_STATUS:
		{
			int32 pages = fNavigator.PageCount();
			int32 currentPage = fNavigator.CurrentPage();

			_EnableMenuItem(fBar, MSG_PAGE_FIRST,
				fNavigator.HasPreviousPage());
			_EnableMenuItem(fBar, MSG_PAGE_LAST, fNavigator.HasNextPage());
			_EnableMenuItem(fBar, MSG_PAGE_NEXT, fNavigator.HasNextPage());
			_EnableMenuItem(fBar, MSG_PAGE_PREV, fNavigator.HasPreviousPage());
			fGoToPageMenu->SetEnabled(pages > 1);

			_EnableMenuItem(fBar, MSG_FILE_NEXT, fNavigator.HasNextFile());
			_EnableMenuItem(fBar, MSG_FILE_PREV, fNavigator.HasPreviousFile());

			if (fGoToPageMenu->CountItems() != pages) {
				// Only rebuild the submenu if the number of
				// pages is different

				while (fGoToPageMenu->CountItems() > 0) {
					// Remove all page numbers
					delete fGoToPageMenu->RemoveItem((int32)0);
				}

				for (int32 i = 1; i <= pages; i++) {
					// Fill Go To page submenu with an entry for each page
					BMessage* goTo = new BMessage(MSG_GOTO_PAGE);
					goTo->AddInt32("page", i);

					char shortcut = 0;
					if (i < 10)
						shortcut = '0' + i;

					BString strCaption;
					strCaption << i;

					BMenuItem* item = new BMenuItem(strCaption.String(), goTo,
						shortcut, B_SHIFT_KEY);
					if (currentPage == i)
						item->SetMarked(true);
					fGoToPageMenu->AddItem(item);
				}
			} else {
				// Make sure the correct page is marked
				BMenuItem* currentItem = fGoToPageMenu->ItemAt(currentPage - 1);
				if (currentItem != NULL && !currentItem->IsMarked())
					currentItem->SetMarked(true);
			}

			_UpdateStatusText(message);

			BPath path(fImageView->Image());
			SetTitle(path.Path());
			break;
		}

		case MSG_UPDATE_STATUS_TEXT:
		{
			_UpdateStatusText(message);
			break;
		}

		case MSG_SELECTION:
		{
			// The view sends this message when a selection is
			// made or the selection is cleared so that the window
			// can update the state of the appropriate menu items
			bool enable;
			if (message->FindBool("has_selection", &enable) == B_OK) {
				_EnableMenuItem(fBar, B_COPY, enable);
				_EnableMenuItem(fBar, MSG_CLEAR_SELECT, enable);
			}
			break;
		}

		case B_COPY:
			fImageView->CopySelectionToClipboard();
			break;

		case MSG_SELECTION_MODE:
		{
			bool selectionMode = _ToggleMenuItem(MSG_SELECTION_MODE);
			fImageView->SetSelectionMode(selectionMode);
			if (!selectionMode)
				fImageView->ClearSelection();
			break;
		}

		case MSG_CLEAR_SELECT:
			fImageView->ClearSelection();
			break;

		case MSG_SELECT_ALL:
			fImageView->SelectAll();
			break;

		case MSG_PAGE_FIRST:
			if (_ClosePrompt() && fNavigator.FirstPage())
				_LoadImage();
			break;

		case MSG_PAGE_LAST:
			if (_ClosePrompt() && fNavigator.LastPage())
				_LoadImage();
			break;

		case MSG_PAGE_NEXT:
			if (_ClosePrompt() && fNavigator.NextPage())
				_LoadImage();
			break;

		case MSG_PAGE_PREV:
			if (_ClosePrompt() && fNavigator.PreviousPage())
				_LoadImage();
			break;

		case MSG_GOTO_PAGE:
		{
			if (!_ClosePrompt())
				break;

			int32 newPage;
			if (message->FindInt32("page", &newPage) != B_OK)
				break;

			int32 currentPage = fNavigator.CurrentPage();
			int32 pages = fNavigator.PageCount();

			// TODO: use radio mode instead!
			if (newPage > 0 && newPage <= pages) {
				BMenuItem* currentItem = fGoToPageMenu->ItemAt(currentPage - 1);
				BMenuItem* newItem = fGoToPageMenu->ItemAt(newPage - 1);
				if (currentItem != NULL && newItem != NULL) {
					currentItem->SetMarked(false);
					newItem->SetMarked(true);
					if (fNavigator.GoToPage(newPage))
						_LoadImage();
				}
			}
			break;
		}

		case kMsgFitToWindow:
			fImageView->FitToBounds();
			break;

		case kMsgStretchToWindow:
			fImageView->SetStretchToBounds(
				_ToggleMenuItem(kMsgStretchToWindow));
			break;

		case MSG_FILE_PREV:
			if (_ClosePrompt() && fNavigator.PreviousFile())
				_LoadImage(false);
			break;

		case MSG_FILE_NEXT:
		case kMsgNextSlide:
			if (_ClosePrompt() && fNavigator.NextFile())
				_LoadImage();
			break;

		case kMsgDeleteCurrentFile:
		{
			if (fNavigator.MoveFileToTrash())
				_LoadImage();
			else
				PostMessage(B_QUIT_REQUESTED);
			break;
		}

		case MSG_ROTATE_90:
			fImageView->Rotate(90);
			break;

		case MSG_ROTATE_270:
			fImageView->Rotate(270);
			break;

		case MSG_FLIP_LEFT_TO_RIGHT:
			fImageView->Flip(true);
			break;

		case MSG_FLIP_TOP_TO_BOTTOM:
			fImageView->Flip(false);
			break;

		case MSG_SLIDE_SHOW:
		{
			bool fullScreen = false;
			message->FindBool("full screen", &fullScreen);

			BMenuItem* item = fBar->FindItem(message->what);
			if (item == NULL)
				break;

			if (item->IsMarked()) {
				item->SetMarked(false);
				_StopSlideShow();
				fToolBar->SetActionPressed(MSG_SLIDE_SHOW, false);
			} else if (_ClosePrompt()) {
				item->SetMarked(true);
				if (!fFullScreen && fullScreen)
					_ToggleFullScreen();
				_StartSlideShow();
				fToolBar->SetActionPressed(MSG_SLIDE_SHOW, true);
			}
			break;
		}

		case kMsgStopSlideShow:
		{
			BMenuItem* item = fBar->FindItem(MSG_SLIDE_SHOW);
			if (item != NULL)
				item->SetMarked(false);

			_StopSlideShow();
			fToolBar->SetActionPressed(MSG_SLIDE_SHOW, false);
			break;
		}

		case MSG_SLIDE_SHOW_DELAY:
		{
			bigtime_t delay;
			if (message->FindInt64("delay", &delay) == B_OK) {
				_SetSlideShowDelay(delay);
				// in case message is sent from popup menu
				_MarkSlideShowDelay(delay);
			}
			break;
		}

		case MSG_FULL_SCREEN:
			_ToggleFullScreen();
			break;

		case MSG_EXIT_FULL_SCREEN:
			if (fFullScreen)
				_ToggleFullScreen();
			break;

		case MSG_SHOW_CAPTION:
		{
			fShowCaption = _ToggleMenuItem(message->what);
			ShowImageSettings* settings = my_app->Settings();

			if (settings->Lock()) {
				settings->SetBool("ShowCaption", fShowCaption);
				settings->Unlock();
			}
			if (fFullScreen)
				fImageView->SetShowCaption(fShowCaption);
		}	break;

		case MSG_PAGE_SETUP:
			_PageSetup();
			break;

		case MSG_PREPARE_PRINT:
			_PrepareForPrint();
			break;

		case MSG_PRINT:
			_Print(message);
			break;

		case MSG_ZOOM_IN:
			fImageView->ZoomIn();
			break;

		case MSG_ZOOM_OUT:
			fImageView->ZoomOut();
			break;

		case MSG_UPDATE_STATUS_ZOOM:
			fStatusView->SetZoom(fImageView->Zoom());
			break;

		case kMsgOriginalSize:
			if (message->FindInt32("behavior") == BButton::B_TOGGLE_BEHAVIOR) {
				bool force = (message->FindInt32("be:value") == B_CONTROL_ON);
				fImageView->ForceOriginalSize(force);
				if (!force)
					break;
			}
			fImageView->SetZoom(1.0);
			break;

		case MSG_SCALE_BILINEAR:
			fImageView->SetScaleBilinear(_ToggleMenuItem(message->what));
			break;

		case MSG_DESKTOP_BACKGROUND:
		{
			BMessage backgroundsMessage(B_REFS_RECEIVED);
			backgroundsMessage.AddRef("refs", fImageView->Image());
			// This is used in the Backgrounds code for scaled placement
			backgroundsMessage.AddInt32("placement", 'scpl');
			be_roster->Launch("application/x-vnd.haiku-backgrounds",
				&backgroundsMessage);
			break;
		}

		case MSG_SET_RATING:
		{
			int32 rating;
			if (message->FindInt32("rating", &rating) != B_OK)
				break;
			BFile file(&fNavigator.CurrentRef(), B_WRITE_ONLY);
			if (file.InitCheck() != B_OK)
				break;
			file.WriteAttr("Media:Rating", B_INT32_TYPE, 0, &rating,
				sizeof(rating));
			_UpdateRatingMenu();
			break;
		}

		case kMsgToggleToolBar:
		{
			fShowToolBar = _ToggleMenuItem(message->what);
			_SetToolBarVisible(fShowToolBar, true);

			ShowImageSettings* settings = my_app->Settings();

			if (settings->Lock()) {
				settings->SetBool("ShowToolBar", fShowToolBar);
				settings->Unlock();
			}
			break;
		}
		case kShowToolBarIfEnabled:
		{
			bool show;
			if (message->FindBool("show", &show) != B_OK)
				break;
			_SetToolBarVisible(fShowToolBar && show, true);
			break;
		}
		case kMsgSlideToolBar:
		{
			float offset;
			if (message->FindFloat("offset", &offset) == B_OK) {
				fToolBar->MoveBy(0, offset);
				fScrollView->ResizeBy(0, -offset);
				fScrollView->MoveBy(0, offset);
				UpdateIfNeeded();
				snooze(15000);
			}
			break;
		}
		case kMsgFinishSlidingToolBar:
		{
			float offset;
			bool show;
			if (message->FindFloat("offset", &offset) == B_OK
				&& message->FindBool("show", &show) == B_OK) {
				// Compensate rounding errors with the final placement
				fToolBar->MoveTo(fToolBar->Frame().left, offset);
				if (!show)
					fToolBar->Hide();
				BRect frame = fToolBar->Parent()->Bounds();
				frame.top = fToolBar->Frame().bottom + 1;
				fScrollView->MoveTo(fScrollView->Frame().left, frame.top);
				fScrollView->ResizeTo(fScrollView->Bounds().Width(),
					frame.Height() + 1);
			}
			break;
		}

		default:
			BWindow::MessageReceived(message);
			break;
	}
}
Esempio n. 23
0
void GfxText16::ShowString(const Common::String &str, GuiResourceId orgFontId, int16 orgPenColor) {
	Show(str.c_str(), 0, str.size(), orgFontId, orgPenColor);
}
	TestWindow() : dle::Window( BRect(100,100,199,199), "DLE Test1", B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, 0 )
	{
		Show();
	}
//-----------------------------------------------------------------------------
// Purpose: Handle player_death message
//-----------------------------------------------------------------------------
void CDODDeathStatsPanel::FireGameEvent( IGameEvent * event)
{
	if ( Q_strcmp( "player_death", event->GetName() ) == 0 )
	{	
		C_BasePlayer *pLocalPlayer = C_BasePlayer::GetLocalPlayer();

		if ( !pLocalPlayer )
			return;

		if ( !g_PR )
			return;

		int victim = engine->GetPlayerForUserID( event->GetInt("userid") );

		// only deal with deathnotices where we die
		if ( victim != pLocalPlayer->entindex() )
		{
			return;
		}

		int killer = engine->GetPlayerForUserID( event->GetInt("attacker") );
		
		const char *killedwith = event->GetString( "weapon" );

		char fullkilledwith[128];
		if ( killedwith && *killedwith )
		{
			Q_snprintf( fullkilledwith, sizeof(fullkilledwith), "d_%s", killedwith );
		}
		else
		{
			fullkilledwith[0] = 0;
		}

		// Get the names of the players
		const char *killer_name = g_PR->GetPlayerName( killer );
		const char *victim_name = g_PR->GetPlayerName( victim );

		if ( !killer_name )
			killer_name = "";
		if ( !victim_name )
			victim_name = "";

		m_DeathRecord.Killer.iEntIndex = killer;
		m_DeathRecord.Victim.iEntIndex = victim;
		Q_strncpy( m_DeathRecord.Killer.szName, killer_name, MAX_PLAYER_NAME_LENGTH );
		Q_strncpy( m_DeathRecord.Victim.szName, victim_name, MAX_PLAYER_NAME_LENGTH );
		m_DeathRecord.bSuicide = ( !killer || killer == victim );

		// Try and find the death identifier in the icon list
		m_DeathRecord.iconDeath = gHUD.GetIcon( fullkilledwith );

		if ( !m_DeathRecord.iconDeath )
		{
			// Can't find it, so use the default skull & crossbones icon
			m_DeathRecord.iconDeath = m_iconD_skull;
		}

		// Info we get from this message:
		// - who killed us with what

		// Info that is networked to the local player
		// - the hitgroups we hit the guy who killed us with
		// - life kills
		// - life woundings
		// - life caps
		// - life defenses

		Show();
	}	
}
Esempio n. 26
0
int main()
{
    //basic
    std::cout << Double(Double(2)) << std::endl;
    std::cout << Double(3.14) << std::endl;
    std::cout << Double(2.222222) << std::endl;
    
    PrintPower(10);
    PrintPower(3.14);
    PrintPower(2.222);
    
    Neshto drugo(20);
    PrintPower(drugo);
    std::cout << add(5, 10) << std::endl;
    
    int a = 10, b = 20;
    std::cout << "a: " << a << std::endl << "b: " << b << std::endl;
    std::cout << "swap..." << std::endl;

    swap(a, b);
    std::cout << "a: " << a << std::endl << "b: " << b << std::endl;

    //arrays
    int p();
    std::cout << "p: " << p << std::endl;
    int q();
    std::cout << "q: " << q << std::endl;
    std::cout << "int(): " << int() << std::endl;
    
    int arr[10] = {1,2,3,4,5,6,7,8,9,10};
    std::cout << "GET AVERAGE: "  << GetAverage<int>(arr, 10) << std::endl;

    float f_arr[5] = {1.1,2.2,3.3,4.4,5.5};
    std::cout << "int args: " << GetAverage<int>(arr, 10) << std::endl;
    std::cout << "float args: " << GetAverage<float>(&f_arr[0], 5) << std::endl;

    std::cout << "float args with int function: " << GetAverage<int>(arr, 5);

    int t = 10;
    std::cout << "t: " << t << std::endl;
    RefAdd(t, 5);
    std::cout << "t: " << t << std::endl;
   
    // This will not be compiled
    // Because we take a const & as
    // argument and the return type
    // is not const When break
    // the constness of the argument
    //int immutable_number = 10;
    //++GetTrival(immutable_number);

    Pair pesho = {20, "Pesho"};
    PrintPair(pesho.age, pesho.name);

    std::string pi_key = "PI";
    double pi_value = 3.14;

    PrintPair(pi_key, pi_value);
    PrintPair("Pesho", "Goshov");

    // print gosho
    User gosho("Gosho", 2000);
    int user_id=25;
    PrintPair(user_id, gosho);
    
    // Note:
    // When we use a template function
    // with similar parameters (e.g. short, int, long)
    // which can be converted to one another
    // the template engine will not reuse the created
    // functions and implicitly convert the arguments
    // Example:
    //      short a = 10;
    //      int b = 200000000;
    //      double c = 2.15;
    //      long d = 40000000000; 40 bilions
    //
    //      PrintPair(a, b); same as PrintPair<short, int> 
    //      PrintPair(b, a); --|-- PrintPair<int, short>
    //      PrintPair(a, d); --|-- PrintPair<short, long>
    //      PrintPair(d, c); --|-- PrintPair<long, double>
    
    Show(120);
    Show('B');
    Show(21.5);

    TemplateShow(120); // will produce TemplateShow<int> 
    TemplateShow('X'); // will produce TemplateShow<char>
    TemplateShow(21.5); // will produce TemplateShow<double>

    // the compiler will not make an analisys
    // of the parameter because the function
    // is called explicitly with type double
    // and the argument will be taken as double
    // although it can be put in int
    TemplateShow<double>(1234); 
    

    // SizeOfElement(); // cannot be called
    SizeOfElement<float>();
    SizeOfElement<int>();
    SizeOfElement<short>();
    SizeOfElement<User>();
    
    int int_arr[10] = {1,2,3,0,4,0,2,0,9,10};
    PrintNumbers(int_arr, 10); // this will skip 0-s
    PrintNumbers(int_arr, 10, 2); // this will skip 2-s

    // TEMPLATE CLASSES USAGE
    Item i1;
    i1.SetData(120);
    i1.PrintData();
    
    TemplateItem<double> t1;
    t1.SetData(3.14);
    t1.PrintData();

    TemplateItem<char> t2;
    t2.SetData('X');
    char big_x = t2.GetData();
    std::cout << big_x << std::endl;
    t2.PrintData();

    //t1 = t2; //this will cause error
    // because t1 is instace of the template
    // class with double and t2 is instance with char

    TemplatePair<int, std::string> t_pair1;
    TemplatePair<int, int> salary;
    salary.first = 200; // leva
    salary.second = 30; // coins
    std::cout << "salary: ";
    salary.Print();
    TemplatePair<int, int> int_pair1(10, 20);
    TemplatePair<int, int> int_pair2(int_pair1);
    int_pair1.Print();
    int_pair2.Print();
    // it will cause an error 
    //TemplatePair<int, float> int_float_pair(int_pair2);


    // Exercise: Implement
    // 1. operator =
    // 2. operator <
    // 3. operator >
    // 4. swap method
    // 5. modify the constructor with default arguments
    int pp;
    int qq = int();
    std::cout << "pp: " << pp << std::endl;
    std::cout << "qq: " << qq << std::endl;

    // Template of template
   TemplateArray<TemplatePair<int, int>, 10> t_arr_t_pair;
   t_arr_t_pair[0] = TemplatePair<int, int>(5, 5); 
    t_arr_t_pair.Print();

    typedef TemplatePair<int, int> Salary;
    TemplatePair<std::string, Salary> peshko;


    std::vector<int> int_vector;
    std::vector<TemplatePair<int, int> > int_pair_vector;

    // this will make a int array of 100 elements
    DefaultTemplateArray<> default_arr_int;

    DefaultTemplateArray<double> def_size_d_arr;


// TEMPLATE METHODS
    
    IntArray int_arr_obj;
    float float_arr[11];
    int_arr_obj.Copy(float_arr);
    // or more explicitely int_arr_obj.Copy<float>(float_arr);
    
    std::cout << "Print int_arr_obj: " << std::endl;
    for(int i = 0; i < 10; ++i)
    {
        std::cout << int_arr_obj[i] << " ";
    }
    std::cout << std::endl;

    std::cout << "Print float_arr: " << std::endl;
    for(int i = 0; i < 10; ++i)
    {
        std::cout << int_arr_obj[i] << " ";
    }
    std::cout << std::endl;

    Comparer<int> c_int(10);
    float c_float = 10;

    std::cout << std::boolalpha << c_int.IsEqual(c_float)
              << std::endl;
    
    Comparer<int> cc_int(40);
    float cc_float;
    double cc_double;

    cc_float = cc_int;
    cc_double = cc_int;
    // which will invoke
    // Comparer<int>::operator<float> float();
    // Comparer<int>::operator<double> double();

    std::cout << "cc_int: " << cc_int.Data() << "\n"
              << "cc_float: " << cc_float << "\n"
              << "cc_double: " << cc_double << "\n";


    return 0;
}
Esempio n. 27
0
void Timer::Dump() {
  if (!Trace::moduleEnabledRelease(Trace::jittime)) return;
  Trace::traceRelease("%s", Show().c_str());
}
Esempio n. 28
0
void ContrastDialog::OnClose(wxCommandEvent & WXUNUSED(event))
{
   Show(false);
}
Esempio n. 29
0
void CSimpleFrame::OnConnect(CFrameEvent& WXUNUSED(event)) {
    wxLogTrace(wxT("Function Start/End"), wxT("CSimpleFrame::OnConnect - Function Begin"));
    
    CMainDocument*     pDoc = wxGetApp().GetDocument();
    CWizardAttach*     pWizard = NULL;
    wxString strComputer = wxEmptyString;
    wxString strName = wxEmptyString;
    wxString strURL = wxEmptyString;
    wxString strTeamName = wxEmptyString;
    std::string strProjectName;
    std::string strProjectURL;
    std::string strProjectAuthenticator;
    std::string strProjectInstitution;
    std::string strProjectDescription;
    std::string strProjectKnown;
    bool bCachedCredentials = false;
    ACCT_MGR_INFO ami;
    PROJECT_INIT_STATUS pis;
	CC_STATUS     status;
    int wasShown = 0;
    int wasVisible = 0;

    wxASSERT(pDoc);
    wxASSERT(wxDynamicCast(pDoc, CMainDocument));

    pDoc->ForceCacheUpdate();
    pDoc->GetCoreClientStatus(status, true);

	// If we are connected to the localhost, run a really quick screensaver
    //   test to trigger a firewall popup.
    pDoc->GetConnectedComputerName(strComputer);
    if (pDoc->IsComputerNameLocal(strComputer)) {
        wxGetApp().StartBOINCScreensaverTest();
        wxGetApp().StartBOINCDefaultScreensaverTest();
    }


    pDoc->rpc.get_project_init_status(pis);
    pDoc->rpc.acct_mgr_info(ami);

    if (detect_simple_account_credentials(
            strProjectName, strProjectURL, strProjectAuthenticator, strProjectInstitution, strProjectDescription, strProjectKnown
        )
    ){
        if (!pDoc->project((char*)strProjectURL.c_str())) {
            wasShown = IsShown();
            Show();
            wasVisible = wxGetApp().IsApplicationVisible();
            if (!wasVisible) {
                wxGetApp().ShowApplication(true);
            }
        
            pWizard = new CWizardAttach(this);

            pWizard->RunSimpleProjectAttach(
                wxURI::Unescape(strProjectName),
                wxURI::Unescape(strProjectURL),
                wxURI::Unescape(strProjectAuthenticator),
                wxURI::Unescape(strProjectInstitution),
                wxURI::Unescape(strProjectDescription),
                wxURI::Unescape(strProjectKnown)
            );
        }
    } else if (ami.acct_mgr_url.size() && ami.have_credentials) {
        // Fall through
        //
        // There isn't a need to bring up the attach wizard, the account manager will
        // take care of ataching to projects when it completes the RPCs
        //
    } else if (ami.acct_mgr_url.size() && !ami.have_credentials) {
        wasShown = IsShown();
        Show();
        wasVisible = wxGetApp().IsApplicationVisible();
        if (!wasVisible) {
            wxGetApp().ShowApplication(true);
        }

        pWizard = new CWizardAttach(this);
        if (pWizard->SyncToAccountManager()) {

            // _GRIDREPUBLIC, _PROGRESSTHRUPROCESSORS and _CHARITYENGINE
            // are defined for those branded builds on Windows only
#if defined(_GRIDREPUBLIC) || defined(_PROGRESSTHRUPROCESSORS) || defined(_CHARITYENGINE) || defined(__WXMAC__)
#ifdef __WXMAC__
            // For GridRepublic, Charity Engine or ProgressThruProcessors, 
            // the Mac installer put a branding file in our data directory
            long iBrandID = 0;  // 0 is unbranded (default) BOINC

            FILE *f = boinc_fopen("/Library/Application Support/BOINC Data/Branding", "r");
            if (f) {
                fscanf(f, "BrandId=%ld\n", &iBrandID);
                fclose(f);
            }
            if ((iBrandID > 0) && (iBrandID < 4))
#endif
            {
                // If successful, hide the main window if we showed it
                if (!wasVisible) {
                    wxGetApp().ShowApplication(false);
                }
#ifndef __WXMAC__   // See comment in CBOINCGUIApp::OnFinishInit()
                if (!wasShown) {
                    Hide();
                }
#endif
            }
#endif
        }
    } else if ((pis.url.size() || (0 >= pDoc->GetSimpleProjectCount())) && !status.disallow_attach) {
        Show();
        wxGetApp().ShowApplication(true);

        strURL = wxString(pis.url.c_str(), wxConvUTF8);
        bCachedCredentials = pis.url.length() && pis.has_account_key;

        pWizard = new CWizardAttach(this);
        pWizard->Run(strURL, bCachedCredentials);
    }

 	if (pWizard) {
        pWizard->Destroy();
        m_pBackgroundPanel->UpdateProjectView();
	}

    wxLogTrace(wxT("Function Start/End"), wxT("CSimpleFrame::OnConnect - Function End"));
}
Esempio n. 30
0
bool CSettingsDialog::LoadPages()
{
	// Get the tree control.

	wxTreeCtrl* treeCtrl = XRCCTRL(*this, "ID_TREE", wxTreeCtrl);
	wxASSERT(treeCtrl);
	if (!treeCtrl)
		return false;

	wxTreeItemId root = treeCtrl->AddRoot(_T(""));

	// Create the instances of the page classes and fill the tree.
	t_page page;
	ADD_PAGE(_("Connection"), COptionsPageConnection, page_none);
	ADD_PAGE(_("FTP"), COptionsPageConnectionFTP, page_connection);
	ADD_PAGE(_("Active mode"), COptionsPageConnectionActive, page_connection_ftp);
	ADD_PAGE(_("Passive mode"), COptionsPageConnectionPassive, page_connection_ftp);
	ADD_PAGE(_("FTP Proxy"), COptionsPageFtpProxy, page_connection_ftp);
	ADD_PAGE(_("SFTP"), COptionsPageConnectionSFTP, page_connection);
	ADD_PAGE(_("Generic proxy"), COptionsPageProxy, page_connection);
	ADD_PAGE(_("Transfers"), COptionsPageTransfer, page_none);
	ADD_PAGE(_("File Types"), COptionsPageFiletype, page_transfer);
	ADD_PAGE(_("File exists action"), COptionsPageFileExists, page_transfer);
	ADD_PAGE(_("Interface"), COptionsPageInterface, page_none);
	ADD_PAGE(_("Themes"), COptionsPageThemes, page_interface);
	ADD_PAGE(_("Date/time format"), COptionsPageDateFormatting, page_interface);
	ADD_PAGE(_("Filesize format"), COptionsPageSizeFormatting, page_interface);
	ADD_PAGE(_("File lists"), COptionsPageFilelists, page_interface);
	ADD_PAGE(_("Language"), COptionsPageLanguage, page_none);
	ADD_PAGE(_("File editing"), COptionsPageEdit, page_none);
	ADD_PAGE(_("Filetype associations"), COptionsPageEditAssociations, page_edit);
#if FZ_MANUALUPDATECHECK && FZ_AUTOUPDATECHECK
	if (!COptions::Get()->GetDefaultVal(DEFAULT_DISABLEUPDATECHECK))
	{
		ADD_PAGE(_("Update Check"), COptionsPageUpdateCheck, page_none);
	}
#endif //FZ_MANUALUPDATECHECK && FZ_AUTOUPDATECHECK
	ADD_PAGE(_("Logging"), COptionsPageLogging, page_none);
	ADD_PAGE(_("Debug"), COptionsPageDebug, page_none);

	treeCtrl->SetQuickBestSize(false);
	treeCtrl->InvalidateBestSize();
	treeCtrl->SetInitialSize();
	
	// Compensate for scrollbar
	wxSize size = treeCtrl->GetBestSize();
	int scrollWidth = wxSystemSettings::GetMetric(wxSYS_VSCROLL_X, treeCtrl);
	size.x += scrollWidth;
	size.y = 0;
	treeCtrl->SetInitialSize(size);
	Layout();

	// Before we can initialize the pages, get the target panel in the settings
	// dialog.
	wxPanel* parentPanel = XRCCTRL(*this, "ID_PAGEPANEL", wxPanel);
	wxASSERT(parentPanel);
	if (!parentPanel)
		return false;

	// Keep track of maximum page size
	size = wxSize();

	for (std::vector<t_page>::iterator iter = m_pages.begin(); iter != m_pages.end(); iter++)
	{
		if (!iter->page->CreatePage(m_pOptions, this, parentPanel, size))
			return false;
	}

	if (!LoadSettings())
	{
		wxMessageBox(_("Failed to load panels, invalid resource files?"));
		return false;
	}

	wxSize canvas;
	canvas.x = GetSize().x - parentPanel->GetSize().x;
	canvas.y = GetSize().y - parentPanel->GetSize().y;

	// Wrap pages nicely
	std::vector<wxWindow*> pages;
	for (unsigned int i = 0; i < m_pages.size(); i++)
	{
		pages.push_back(m_pages[i].page);
	}
	wxGetApp().GetWrapEngine()->WrapRecursive(pages, 1.33, "Settings", canvas);

	// Keep track of maximum page size
	size = wxSize(0, 0);
	for (std::vector<t_page>::iterator iter = m_pages.begin(); iter != m_pages.end(); iter++)
		size.IncTo(iter->page->GetSizer()->GetMinSize());

#ifdef __WXGTK__
	size.x += 1;
#endif
	parentPanel->SetInitialSize(size);

	// Adjust pages sizes according to maximum size
	for (std::vector<t_page>::iterator iter = m_pages.begin(); iter != m_pages.end(); iter++)
	{
		iter->page->GetSizer()->SetMinSize(size);
		iter->page->GetSizer()->Fit(iter->page);
		iter->page->GetSizer()->SetSizeHints(iter->page);
	}

	GetSizer()->Fit(this);
	GetSizer()->SetSizeHints(this);

#ifdef __WXGTK__
	// Pre-show dialog under GTK, else panels won't get initialized properly
	Show();
#endif

	for (std::vector<t_page>::iterator iter = m_pages.begin(); iter != m_pages.end(); iter++)
		iter->page->Hide();

	// Select first page
	treeCtrl->SelectItem(m_pages[0].id);
	if (!m_activePanel)
	{
		m_activePanel = m_pages[0].page;
		m_activePanel->Display();
	}

	return true;
}