コード例 #1
0
ファイル: Camera.cpp プロジェクト: rickcaudill/Pyro
void DockCamera::MouseMove( const os::Point& cNewPos, int nCode, uint32 nButtons, os::Message* pcData )
{
	if (nCode == MOUSE_INSIDE)
	{
		if (m_bHover)
		{
			Bitmap* pcBitmap = m_pcIcon->LockBitmap();
			m_bHover = false;
			if( pcPaint == NULL )
			{
				pcPaint = new BitmapImage(pcBitmap->LockRaster(),IPoint((int)m_pcIcon->GetSize().x,(int)m_pcIcon->GetSize().y),pcBitmap->GetColorSpace());;
				pcPaint->ApplyFilter(BitmapImage::F_HIGHLIGHT);
				pcBitmap->UnlockRaster();
				pcPaint->UnlockBitmap();
			}
			Invalidate(GetBounds());
			Flush();
		}
	}

	else
	{
		m_bHover = true;
		Invalidate(GetBounds());
		Flush();
	}

	if( nCode != MOUSE_ENTERED && nCode != MOUSE_EXITED )
	{
		/* Create dragging operation */
		if( m_bCanDrag )
		{
			BitmapImage* pcIcon = m_pcIcon;
			m_bDragging = true;
			os::Message* pcMsg = new os::Message();
			BeginDrag( pcMsg, os::Point( pcIcon->GetBounds().Width() / 2,
											pcIcon->GetBounds().Height() / 2 ),pcIcon->LockBitmap() );
			delete( pcMsg );
			m_bCanDrag = false;
			Paint(GetBounds());
		}
	}

	os::View::MouseMove( cNewPos, nCode, nButtons, pcData );
}
コード例 #2
0
ファイル: icon.cpp プロジェクト: PyroOS/Pyro
void Icon::Paint( const Rect &cUpdateRect )
{
	EraseRect( cUpdateRect );

	if( m_bSelected )
	{
		Rect cUpdateFrame = GetBounds();
		cUpdateFrame.top += 2;
		cUpdateFrame.left += 2;

		/* XXXKV: This is a hack; why is the height from GetBounds() so large? */
		cUpdateFrame.right = m_cSize.x - 2;
		cUpdateFrame.bottom = m_cSize.y - 2;

		FillRect( cUpdateFrame, m_sHighlightColor );

		/* Round edges */
		SetDrawingMode( DM_COPY );
		SetFgColor( m_sHighlightColor );

		DrawLine( os::Point( cUpdateFrame.left + 2, cUpdateFrame.top - 2 ), 
					os::Point( cUpdateFrame.right - 2, cUpdateFrame.top - 2 ) );
		DrawLine( os::Point( cUpdateFrame.left, cUpdateFrame.top - 1 ), 
					os::Point( cUpdateFrame.right, cUpdateFrame.top - 1 ) );
			
		DrawLine( os::Point( cUpdateFrame.left - 2, cUpdateFrame.top + 2 ), 
					os::Point( cUpdateFrame.left - 2, cUpdateFrame.bottom - 2 ) );
		DrawLine( os::Point( cUpdateFrame.left - 1, cUpdateFrame.top ), 
					os::Point( cUpdateFrame.left - 1, cUpdateFrame.bottom ) );
								
		DrawLine( os::Point( cUpdateFrame.left + 2, cUpdateFrame.bottom + 2 ), 
					os::Point( cUpdateFrame.right - 2, cUpdateFrame.bottom + 2 ) );
		DrawLine( os::Point( cUpdateFrame.left, cUpdateFrame.bottom + 1 ), 
					os::Point( cUpdateFrame.right, cUpdateFrame.bottom + 1 ) );
								
		DrawLine( os::Point( cUpdateFrame.right + 2, cUpdateFrame.top + 2 ), 
						os::Point( cUpdateFrame.right + 2, cUpdateFrame.bottom - 2 ) );
		DrawLine( os::Point( cUpdateFrame.right + 1, cUpdateFrame.top ), 
					os::Point( cUpdateFrame.right + 1, cUpdateFrame.bottom ) );

		SetFgColor( m_sFgColor );
	}

	SetDrawingMode( DM_BLEND );

	/* XXXKV: Will only work with BitmapImage; should use RTTI to find
	   type and handle accordingly */
	BitmapImage *pcImage = static_cast<BitmapImage*>( m_pcImage );
	Bitmap *pcBitmap = pcImage->LockBitmap();
	DrawBitmap( pcBitmap, pcImage->GetBounds(), m_cImageFrame );
	pcImage->UnlockBitmap();

	/* Draw the icon name */
	SetDrawingMode( DM_OVER );
	MovePenTo( m_cNamePos );
	DrawString( m_cName );
}
コード例 #3
0
ファイル: Camera.cpp プロジェクト: rickcaudill/Pyro
void DockCamera::HandleMessage(Message* pcMessage)
{
	switch (pcMessage->GetCode())
	{
		case M_CAMERA_ABOUT:
		{
			String cTitle = (String)"About " + (String)PLUGIN_NAME + (String)"...";
			String cInfo = (String)"Version:  " +  (String)PLUGIN_VERSION + (String)"\n\nAuthor:   " + (String)PLUGIN_AUTHOR + (String)"\n\nDesc:      " + (String)PLUGIN_DESC;	
			Alert* pcAlert = new Alert(cTitle.c_str(),cInfo.c_str(),m_pcIcon->LockBitmap(),0,"OK",NULL);
			pcAlert->Go(new Invoker());
			pcAlert->MakeFocus();
			break;
		}
		case M_PREFS:
		{
			ShowPrefs(m_pcPlugin->GetPath());
			break;
		}
		
		case M_PREFS_SEND_TO_PARENT:
		{
			pcMessage->FindFloat("click",&vClick);
			pcMessage->FindFloat("key/instant",&vInstant);
			pcMessage->FindFloat("key/delay",&vDelay);
			pcMessage->FindFloat("delay",&vDelayTime);
			SaveSettings();
			LoadSettings();
			pcPrefsWin->Close();
			pcPrefsWin = NULL;			
		
			break;
		}
		
		case M_PRINT_SCREEN:
		{
			if (bFirst)
			{
				bFirst = false;
			}
			else
			{	
				pcCameraDelayedLooper->AddTimer(pcCameraDelayedLooper,CAMERA_ID,0);
			}
			break;
		}		
	}
}
コード例 #4
0
ファイル: tailwin.cpp プロジェクト: rickcaudill/Pyro
TailWin::TailWin(const Rect & r, const String & file, uint32 desktopmask)
	:Window(r, "TailWin", os::String("Monitor: ") + file, 0, desktopmask)
{
	Rect bounds = GetBounds();

	m_TextView = new TailView(bounds, "tv", "", CF_FOLLOW_ALL, /*WID_FULL_UPDATE_ON_RESIZE|*/WID_WILL_DRAW);
	
	m_TextView->SetMultiLine(true);
	m_TextView->SetReadOnly(true);
	m_TextView->MakeFocus(true);

	AddShortcut( ShortcutKey(STR_POPUPMENU_COPY_SH), new Message(ID_COPY) );
	AddShortcut( ShortcutKey(STR_POPUPMENU_CLEAR_SH), new Message(ID_CLEAR) );
	AddShortcut( ShortcutKey(STR_POPUPMENU_SAVE_SH), new Message(ID_SAVE) );
	AddShortcut( ShortcutKey(STR_POPUPMENU_ABOUT_SH), new Message(ID_ABOUT) );
	AddShortcut( ShortcutKey(STR_POPUPMENU_QUIT_SH), new Message(ID_QUIT) );

	/*Font* pcAppFont = new Font;
	pcAppFont->SetFamilyAndStyle("Lucida Sans Typewriter", "Regular");
	pcAppFont->SetSize(8);

	m_TextView->SetFont(pcAppFont);
	pcAppFont->Release();
	*/
	AddChild(m_TextView);

		/* Set the application icon */
	Resources cRes( get_image_id() );
	BitmapImage	*pcAppIcon = new BitmapImage();
	pcAppIcon->Load( cRes.GetResourceStream( "icon48x48.png" ) );
	SetIcon( pcAppIcon->LockBitmap() );
	delete( pcAppIcon );
	
	m_FileName = new String(file);
	m_LastSize = -1;

	Tail();

	AddTimer(this, 10, 1000000, false);
	// Tried using NodeMonitor, but it doesn't trigger until the file
	// is closed/opened or touched somehow. Just keeping it open and
	// writing doesn't trigger the node monitor, and most log files
	// are handled just like that...
}
コード例 #5
0
/*************************************************
* Description: Handles messages passed to it
* Author: Rick Caudill
* Date: Thu Mar 18 20:17:32 2004
**************************************************/
void WallpaperChangerSettings::HandleMessage(Message* pcMessage)
{
	switch (pcMessage->GetCode())
	{
		/*case M_NODE_MONITOR:
		{
			pcDirectoryList->Clear();
			LoadDirectoryList();
			break;
		}*/
		
		case M_APPLY:
		{
			SaveSettings();
			break;
		}
		
		case M_CANCEL:
		{
			Message* pcMsg = new Message(M_PREFS_CANCEL);
			pcParentLooper->PostMessage(pcMsg,pcParentView);
			break;
		}
		
		case M_DEFAULT:
		{
			break;
		}
		
		case M_CHANGE_IMAGE:
		{
			ListViewStringRow* pcRow = (ListViewStringRow*)pcDirectoryList->GetRow(pcDirectoryList->GetLastSelected());
			String cImage = getenv( "HOME" );
			cImage += String("/Pictures/") + pcRow->GetString(0);
			BitmapImage* pcNewImage = new BitmapImage(new File(cImage));
			Bitmap* pcNewBitmap = new Bitmap(201,90,CS_RGB32);
			Scale(pcNewImage->LockBitmap(),pcNewBitmap,filter_box,0);
			pcNewImage->SetBitmapData(pcNewBitmap->LockRaster(),IPoint(201,90),CS_RGB32);
			pcImageView->SetImage(pcNewImage);
			break;
		}
	}
}
コード例 #6
0
ファイル: main.cpp プロジェクト: PyroOS/Pyro
BrowserWindow::BrowserWindow( const Rect &cFrame ) : Window( cFrame, "webview_wnd", "Webster" )
{
	Rect cMenuFrame, cToolFrame, cStatusFrame, cTabFrame;

	m_pcChromeClient = new BrowserChromeClient( this );
	m_pcWebSettings = new WebSettings();
	m_pcWebSettings->Load();

	m_pcSettings = new Settings();
	m_pcSettings->Load();

	/* Get window layouts */
	m_pcGuiSettings = new Settings();
	m_pcGuiSettings->SetFile( "Gui" );
	m_pcGuiSettings->Load();

	m_cWindowFrame = m_pcGuiSettings->GetRect( "webster", cFrame );
	m_cSettingsFrame = m_pcGuiSettings->GetRect( "settings", Rect( 25, 25, 600, 450 ) );

	SetFrame( m_cWindowFrame );
	cMenuFrame = cToolFrame = cStatusFrame = cTabFrame = GetBounds();

	/* DANGER WILL ROBINSON! See the note in the BrowserApp constructor about this mutex! */
	g_cGlobalMutex.Lock();
	SetMutex( &g_cGlobalMutex );

	m_pcMenuBar = new Menu( cMenuFrame, "menubar", ITEMS_IN_ROW );

	Menu *pcApplicationMenu = new Menu( Rect(), "Application", ITEMS_IN_COLUMN );
	pcApplicationMenu->AddItem( "Quit", new Message( M_TERMINATE ), "Ctrl+Q" );
	pcApplicationMenu->AddItem( new MenuSeparator() );
	pcApplicationMenu->AddItem( "About Webster", new Message( ID_MENU_APP_ABOUT ) );
	m_pcMenuBar->AddItem( pcApplicationMenu );

	Menu *pcWindowMenu = new Menu( Rect(), "Window", ITEMS_IN_COLUMN );
	pcWindowMenu->AddItem( "New window", new Message( ID_CREATE_WINDOW ), "Ctrl+N" );
	pcWindowMenu->AddItem( "Close window", new Message( M_QUIT ), "Ctrl+W" );
	pcWindowMenu->AddItem( new MenuSeparator() );
	pcWindowMenu->AddItem( "New tab", new Message( ID_MENU_WIN_NEW_TAB ), "Ctrl+T" );
	pcWindowMenu->AddItem( "Close tab", new Message( ID_MENU_WIN_CLOSE_TAB ) );
	m_pcMenuBar->AddItem( pcWindowMenu );

	Menu *pcEditMenu = new Menu( Rect(), "Edit", ITEMS_IN_COLUMN );
	pcEditMenu->AddItem( "Cut", new Message( ID_MENU_EDIT_CUT ), "Ctrl+X" );
	pcEditMenu->AddItem( "Copy", new Message( ID_MENU_EDIT_COPY ), "Ctrl+C" );
	pcEditMenu->AddItem( "Paste", new Message( ID_MENU_EDIT_PASTE ), "Ctrl+V" );
	pcEditMenu->AddItem( new MenuSeparator() );
	pcEditMenu->AddItem( "Delete", new Message( ID_MENU_EDIT_DELETE ) );
	m_pcMenuBar->AddItem( pcEditMenu );

	Menu *pcSettingsMenu = new Menu( Rect(), "Settings", ITEMS_IN_COLUMN );
	pcSettingsMenu->AddItem( "Configure", new Message( ID_MENU_SETTINGS_CONFIGURE ) );
	m_pcMenuBar->AddItem( pcSettingsMenu );

	m_pcBookmarksManager = new BookmarksManager();
	BookmarksMenu *pcBookmarksMenu = m_pcBookmarksManager->CreateMenu( "Bookmarks", Path( "" ) );
	m_pcMenuBar->AddItem( pcBookmarksMenu );

	m_pcMenuBar->SetTargetForItems( this );

	cMenuFrame.bottom = m_pcMenuBar->GetPreferredSize( false ).y;
	m_pcMenuBar->SetFrame( cMenuFrame );
	AddChild( m_pcMenuBar );

	/* Setup the toolbar */
	bool bShowButtonText = m_pcSettings->GetBool( "show_button_text", true );
	m_pcToolBar = new ToolBar( Rect(), "toolbar", CF_FOLLOW_LEFT | CF_FOLLOW_RIGHT | CF_FOLLOW_TOP );

	ResStream *pcStream;
	File cSelf( open_image_file( get_image_id() ) );
	Resources cCol( &cSelf );		

	m_pcBackButton = new ImageButton( Rect(), "back", "Back", new Message(ID_BUTTON_BACK), NULL, ImageButton::IB_TEXT_BOTTOM, true, bShowButtonText, true );
	pcStream = cCol.GetResourceStream( "back.png" );
	m_pcBackButton->SetImage( pcStream );
	delete( pcStream );

	m_pcForwardButton = new ImageButton( Rect(), "foward", "Forward", new Message(ID_BUTTON_FORWARD), NULL, ImageButton::IB_TEXT_BOTTOM, true, bShowButtonText, true );
	pcStream = cCol.GetResourceStream( "forward.png" );
	m_pcForwardButton->SetImage( pcStream );
	delete( pcStream );

	m_pcReloadButton = new ImageButton( Rect(), "reload", "Reload", new Message(ID_BUTTON_RELOAD), NULL, ImageButton::IB_TEXT_BOTTOM, true, bShowButtonText, true );
	pcStream = cCol.GetResourceStream( "reload.png" );
	m_pcReloadButton->SetImage( pcStream );
	delete( pcStream );

	m_pcStopButton = new ImageButton( Rect(), "stop", "Stop", new Message(ID_BUTTON_STOP), NULL, ImageButton::IB_TEXT_BOTTOM, true, bShowButtonText, true );
	pcStream = cCol.GetResourceStream( "stop.png" );
	m_pcStopButton->SetImage( pcStream );
	delete( pcStream );

	m_pcHomeButton = new ImageButton( Rect(), "home", "Home", new Message(ID_BUTTON_HOME), NULL, ImageButton::IB_TEXT_BOTTOM, true, bShowButtonText, true );
	pcStream = cCol.GetResourceStream( "home.png" );
	m_pcHomeButton->SetImage( pcStream );
	delete( pcStream );

	m_pcBackButton->SetEnable( false );
	m_pcForwardButton->SetEnable( false );
	m_pcStopButton->SetEnable( false );

	m_pcToolBar->AddChild( m_pcBackButton, ToolBar::TB_FIXED_WIDTH );
	m_pcToolBar->AddChild( m_pcForwardButton, ToolBar::TB_FIXED_WIDTH );
	m_pcToolBar->AddChild( m_pcReloadButton, ToolBar::TB_FIXED_WIDTH );
	m_pcToolBar->AddChild( m_pcStopButton, ToolBar::TB_FIXED_WIDTH );
	m_pcToolBar->AddChild( m_pcHomeButton, ToolBar::TB_FIXED_WIDTH );

	m_pcUrlEdit = new UrlEdit( Rect(), "urledit", CF_FOLLOW_LEFT | CF_FOLLOW_RIGHT | CF_FOLLOW_TOP );
	m_pcUrlEdit->SetMinPreferredSize( 32 );
	m_pcUrlEdit->SetMaxPreferredSize( 256 );
	m_pcUrlEdit->SetEditMessage( new Message( ID_URL_CHANGED ) );
	m_pcUrlEdit->SetSelectionMessage( new Message( ID_URL_CHANGED ) );
	m_pcUrlEdit->SetTarget( this, this );

	m_pcToolBar->AddChild( m_pcUrlEdit, ToolBar::TB_FREE_WIDTH );

	cToolFrame.top = cMenuFrame.bottom + 1.0f;
	cToolFrame.bottom = cToolFrame.top + m_pcToolBar->GetPreferredSize(false).y;
	m_pcToolBar->SetFrame( cToolFrame );
	AddChild( m_pcToolBar );

	m_pcStatusBar = new StatusBar( Rect(), "statusbar", CF_FOLLOW_LEFT | CF_FOLLOW_RIGHT | CF_FOLLOW_BOTTOM );
	m_pcStatusBar->AddPanel( "text", "" );

	m_pcProgress = new ProgressPanel( "progress", 10 );
	m_pcStatusBar->AddPanel( m_pcProgress );

	cStatusFrame.top = cStatusFrame.bottom - 20;
	m_pcStatusBar->SetFrame( cStatusFrame );
	AddChild( m_pcStatusBar );

	cTabFrame.top = cToolFrame.bottom + 1.0f;
	cTabFrame.bottom = cStatusFrame.top - 1.0f;

	m_pcTabView = new TabView( cTabFrame, "webviewtabs", CF_FOLLOW_ALL );
	m_pcTabView->SetMessage( new Message( ID_TAB_CHANGED ) );
	AddChild( m_pcTabView );

	/* Create a tab and open the homepage, if one is configured */
	CreateTab( m_pcSettings->GetString( "homepage", "about:blank" ) );

	/* Set Window icon */
	pcStream = cCol.GetResourceStream( "icon24x24.png" );
	BitmapImage *pcIcon = new BitmapImage( pcStream );
	delete( pcStream );
	SetIcon( pcIcon->LockBitmap() );
	delete( pcIcon );

	/* Nothing is being loaded at this point */
	UpdateButtonState( false );
}