зеркало из https://github.com/mozilla/pjs.git
Changes for the photon platforms.
These changes should not affect the building on other platforms or the runtime on other platforms. Allow the filepicker widget to have multiple selection. Modified nsSound to allow playing of system sound file. Look for Pt_REALIZED flag when building a list of tiles for the widgets in front of the canvas.
This commit is contained in:
Родитель
3e1cd5267a
Коммит
66ea0f943f
|
@ -21,8 +21,11 @@
|
|||
* Adrian Mardare <amardare@qnx.com>
|
||||
*/
|
||||
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsWindow.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIPlatformCharset.h"
|
||||
#include "nsFilePicker.h"
|
||||
|
@ -30,8 +33,8 @@
|
|||
#include "nsIURL.h"
|
||||
#include "nsIFileURL.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsEnumeratorUtils.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
|
||||
static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID);
|
||||
|
@ -93,6 +96,10 @@ NS_IMETHODIMP nsFilePicker::Show(PRInt16 *retval)
|
|||
flags |= Pt_FSR_NO_FCHECK;
|
||||
btn1 = "&Save";
|
||||
}
|
||||
else if( mMode == modeOpenMultiple ) {
|
||||
flags |= Pt_FSR_MULTIPLE;
|
||||
btn1 = "&Select";
|
||||
}
|
||||
else {
|
||||
printf("nsFilePicker::Show() wrong mode");
|
||||
return PR_FALSE;
|
||||
|
@ -159,10 +166,32 @@ NS_IMETHODIMP nsFilePicker::Show(PRInt16 *retval)
|
|||
if( info.ret == Pt_FSDIALOG_BTN2 ) {
|
||||
result = PR_FALSE;
|
||||
}
|
||||
else {
|
||||
else if( mMode != modeOpenMultiple ) {
|
||||
mFile.SetLength(0);
|
||||
mFile.Append( info.path );
|
||||
}
|
||||
else { /* here mMode is modeOpenMultiple */
|
||||
PtFileSelectorInfo_t *minfo = info.minfo;
|
||||
if( minfo ) {
|
||||
nsresult rv = NS_NewISupportsArray(getter_AddRefs(mFiles));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
for( int i=0; i<minfo->nitems; i++ ) {
|
||||
nsCOMPtr<nsILocalFile> file = do_CreateInstance("@mozilla.org/file/local;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
nsCString s ( minfo->multipath[i] );
|
||||
rv = file->InitWithNativePath( s );
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
rv = mFiles->AppendElement(file);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
}
|
||||
|
||||
PtFSFreeInfo( &info ); /* clean the info structure if the multiple mode is set */
|
||||
}
|
||||
}
|
||||
|
||||
PL_strncpyz( mLastUsedDirectory, info.path, PATH_MAX+1 );
|
||||
mDisplayDirectory->InitWithNativePath( nsDependentCString(mLastUsedDirectory) );
|
||||
|
||||
|
@ -193,6 +222,12 @@ NS_IMETHODIMP nsFilePicker::GetFile(nsILocalFile **aFile)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFilePicker::GetFiles(nsISimpleEnumerator **aFiles)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aFiles);
|
||||
return NS_NewArrayEnumerator(aFiles, mFiles);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsFilePicker::GetFileURL(nsIFileURL **aFileURL)
|
||||
{
|
||||
|
|
|
@ -57,6 +57,7 @@ public:
|
|||
NS_IMETHOD GetFileURL(nsIFileURL * *aFileURL);
|
||||
NS_IMETHOD Show(PRInt16 *_retval);
|
||||
NS_IMETHOD AppendFilter(const PRUnichar *aTitle, const PRUnichar *aFilter) ;
|
||||
NS_IMETHOD GetFiles(nsISimpleEnumerator **aFiles);
|
||||
|
||||
protected:
|
||||
// method from nsBaseFilePicker
|
||||
|
@ -81,6 +82,7 @@ protected:
|
|||
nsIUnicodeDecoder* mUnicodeDecoder;
|
||||
nsCOMPtr<nsILocalFile> mDisplayDirectory;
|
||||
PRInt16 mSelectedType;
|
||||
nsCOMPtr <nsISupportsArray> mFiles;
|
||||
|
||||
static char mLastUsedDirectory[];
|
||||
};
|
||||
|
|
|
@ -71,23 +71,6 @@ nsresult nsSound::Init()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
#if 0
|
||||
nsresult NS_NewSound(nsISound** aSound)
|
||||
{
|
||||
NS_PRECONDITION(aSound != nsnull, "null ptr");
|
||||
if (! aSound)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aSound = new nsSound();
|
||||
if (! *aSound)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*aSound);
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
NS_METHOD nsSound::Beep()
|
||||
{
|
||||
::PtBeep();
|
||||
|
@ -97,6 +80,11 @@ NS_METHOD nsSound::Beep()
|
|||
NS_METHOD nsSound::Play(nsIURL *aURL)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("nsSound::Play");
|
||||
|
||||
#ifdef DEBUG
|
||||
printf( "\n\n\nnsSound::Play\n\n" );
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -108,13 +96,32 @@ NS_IMETHODIMP nsSound::OnStreamComplete(nsIStreamLoader *aLoader,
|
|||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf( "\n\n\nnsSound::OnStreamComplete stringData=%s\n\n", stringData );
|
||||
#endif
|
||||
|
||||
if (NS_FAILED(aStatus))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
static void child_exit( void *data, int status ) { }
|
||||
|
||||
NS_IMETHODIMP nsSound::PlaySystemSound(const char *aSoundAlias)
|
||||
{
|
||||
return Beep();
|
||||
#ifdef DEBUG
|
||||
printf( "\n\n\nnsSound::PlaySystemSound aSoundAlias=%s\n\n", aSoundAlias );
|
||||
#endif
|
||||
|
||||
char *soundfile;
|
||||
|
||||
if( !strcmp( "_moz_mailbeep", aSoundAlias ) )
|
||||
soundfile = "/usr/share/mozilla/gotmail.wav";
|
||||
else soundfile = "/usr/share/mozilla/rest.wav";
|
||||
|
||||
const char* argv[] = { "/opt/Mozilla/mozilla/wave", soundfile, NULL };
|
||||
PtSpawn( "/opt/Mozilla/mozilla/wave", ( const char ** ) argv, NULL, NULL, child_exit, NULL, NULL );
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -1263,16 +1263,15 @@ nsWidget* nsWidget::GetInstance( PtWidget_t * pWidget ) {
|
|||
}
|
||||
|
||||
|
||||
// Input keysym is in gtk format; output is in NS_VK format
|
||||
PRUint32 nsWidget::nsConvertKey(unsigned long keysym, PRBool *aIsChar ) {
|
||||
|
||||
struct nsKeyConverter {
|
||||
PRUint32 vkCode; // Platform independent key code
|
||||
unsigned long keysym; // Photon key_sym key code
|
||||
PRBool isChar;
|
||||
};
|
||||
|
||||
struct nsKeyConverter nsKeycodes[] = {
|
||||
struct nsKeyConverter {
|
||||
PRUint32 vkCode; // Platform independent key code
|
||||
unsigned long keysym; // Photon key_sym key code
|
||||
PRBool isChar;
|
||||
};
|
||||
|
||||
static struct nsKeyConverter nsKeycodes[] = {
|
||||
{ NS_VK_CANCEL, Pk_Cancel, PR_FALSE },
|
||||
{ NS_VK_BACK, Pk_BackSpace, PR_FALSE },
|
||||
{ NS_VK_TAB, Pk_Tab, PR_FALSE },
|
||||
|
@ -1326,12 +1325,14 @@ PRUint32 nsWidget::nsConvertKey(unsigned long keysym, PRBool *aIsChar ) {
|
|||
{ NS_VK_PAGE_UP, Pk_KP_9, PR_FALSE }
|
||||
};
|
||||
|
||||
|
||||
// Input keysym is in gtk format; output is in NS_VK format
|
||||
PRUint32 nsWidget::nsConvertKey(unsigned long keysym, PRBool *aIsChar ) {
|
||||
|
||||
const int length = sizeof(nsKeycodes) / sizeof(struct nsKeyConverter);
|
||||
|
||||
if (aIsChar) {
|
||||
/* Default this to TRUE */
|
||||
*aIsChar = PR_TRUE;
|
||||
}
|
||||
*aIsChar = PR_TRUE;
|
||||
|
||||
// First, try to handle alphanumeric input, not listed in nsKeycodes:
|
||||
if (keysym >= Pk_a && keysym <= Pk_z)
|
||||
|
@ -1350,7 +1351,7 @@ PRUint32 nsWidget::nsConvertKey(unsigned long keysym, PRBool *aIsChar ) {
|
|||
|
||||
for (int i = 0; i < length; i++) {
|
||||
if( nsKeycodes[i].keysym == keysym ) {
|
||||
if( aIsChar ) *aIsChar = (nsKeycodes[i].isChar);
|
||||
*aIsChar = (nsKeycodes[i].isChar);
|
||||
return (nsKeycodes[i].vkCode);
|
||||
}
|
||||
}
|
||||
|
@ -1378,8 +1379,8 @@ void nsWidget::InitKeyEvent(PhKeyEvent_t *aPhKeyEvent,
|
|||
unsigned long keysym;
|
||||
if (Pk_KF_Cap_Valid & aPhKeyEvent->key_flags)
|
||||
keysym = nsConvertKey(aPhKeyEvent->key_sym, &IsChar);
|
||||
else
|
||||
keysym = nsConvertKey(aPhKeyEvent->key_cap, &IsChar);
|
||||
else
|
||||
keysym = nsConvertKey(aPhKeyEvent->key_cap, &IsChar);
|
||||
|
||||
anEvent.isShift = ( aPhKeyEvent->key_mods & Pk_KM_Shift ) ? PR_TRUE : PR_FALSE;
|
||||
anEvent.isControl = ( aPhKeyEvent->key_mods & Pk_KM_Ctrl ) ? PR_TRUE : PR_FALSE;
|
||||
|
@ -1435,8 +1436,8 @@ PRBool nsWidget::DispatchKeyEvent( PhKeyEvent_t *aPhKeyEvent ) {
|
|||
w->AddRef();
|
||||
|
||||
if (aPhKeyEvent->key_flags & Pk_KF_Key_Down) {
|
||||
InitKeyEvent(aPhKeyEvent, this, keyEvent, NS_KEY_DOWN);
|
||||
result = w->OnKey(keyEvent);
|
||||
// InitKeyEvent(aPhKeyEvent, this, keyEvent, NS_KEY_DOWN);
|
||||
// result = w->OnKey(keyEvent);
|
||||
|
||||
InitKeyEvent(aPhKeyEvent, this, keyEvent, NS_KEY_PRESS);
|
||||
result = w->OnKey(keyEvent);
|
||||
|
@ -1624,7 +1625,7 @@ PRBool nsWidget::HandleEvent( PtWidget_t *widget, PtCallbackInfo_t* aCbInfo ) {
|
|||
}
|
||||
|
||||
result = DispatchKeyEvent(keyev);
|
||||
#if 1
|
||||
#if 0
|
||||
if ((result == PR_TRUE) && (keyev->key_cap != Pk_Up) && (keyev->key_cap != Pk_Down) &&
|
||||
(keyev->key_cap != Pk_Left) && (keyev->key_cap != Pk_Right) && old_menu && (keyev->key_flags & Pk_KF_Key_Down))
|
||||
{
|
||||
|
|
|
@ -72,6 +72,7 @@
|
|||
#include "nsIPresShell.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
static PhTile_t *GetWindowClipping( PtWidget_t *aWidget );
|
||||
PRBool nsWindow::mResizeQueueInited = PR_FALSE;
|
||||
DamageQueueEntry *nsWindow::mResizeQueue = nsnull;
|
||||
PtWorkProcId_t *nsWindow::mResizeProcID = nsnull;
|
||||
|
@ -802,19 +803,6 @@ void nsWindow::RawDrawFunc( PtWidget_t * pWidget, PhTile_t * damage )
|
|||
nsPaintEvent pev;
|
||||
PhRect_t extent;
|
||||
|
||||
#if 0
|
||||
PgSetFillColor(Pg_WHITE);
|
||||
PgSetDrawMode(Pg_DRAWMODE_XOR);
|
||||
PtWidgetExtent(pWidget, &extent);
|
||||
int i;
|
||||
for (i = 0; i < 5 * 2; i++)
|
||||
{
|
||||
PgDrawRect(&extent, Pg_DRAW_FILL);
|
||||
PgFlush();
|
||||
delay(1);
|
||||
}
|
||||
PgSetDrawMode(Pg_DRAWMODE_OPAQUE);
|
||||
#endif
|
||||
if( !pWin || !pWin->mContext ) return;
|
||||
|
||||
// This prevents redraws while any window is resizing, ie there are
|
||||
|
@ -834,7 +822,7 @@ void nsWindow::RawDrawFunc( PtWidget_t * pWidget, PhTile_t * damage )
|
|||
/* Intersect the Damage tile list w/ the clipped out list and see whats left! */
|
||||
new_damage = PhRectsToTiles(&damage->rect, 1);
|
||||
PhDeTranslateTiles(new_damage, &offset);
|
||||
clip_tiles = pWin->GetWindowClipping();
|
||||
clip_tiles = GetWindowClipping( pWidget );
|
||||
if (clip_tiles) {
|
||||
new_damage = PhClipTilings( new_damage, clip_tiles, NULL);
|
||||
PhFreeTiles(clip_tiles);
|
||||
|
@ -900,8 +888,8 @@ void nsWindow::ScreenToWidget( PhPoint_t &pt ) {
|
|||
}
|
||||
|
||||
|
||||
PhTile_t *nsWindow::GetWindowClipping( ) {
|
||||
PtWidget_t *w, *aWidget = (PtWidget_t *)GetNativeData(NS_NATIVE_WIDGET);
|
||||
static PhTile_t *GetWindowClipping( PtWidget_t *aWidget ) {
|
||||
PtWidget_t *w;
|
||||
PhTile_t *clip_tiles = NULL, *last = NULL;
|
||||
PhRect_t w_extent;
|
||||
|
||||
|
@ -909,7 +897,7 @@ PhTile_t *nsWindow::GetWindowClipping( ) {
|
|||
|
||||
for( w = PtWidgetChildFront( aWidget ); w; w=PtWidgetBrotherBehind( w ) ) {
|
||||
long flags = PtWidgetFlags( w );
|
||||
if( (flags & (Pt_OPAQUE|Pt_REALIZED)) && !(PtIsDisjoint(w))) {
|
||||
if( (flags & Pt_REALIZED) && (flags & Pt_OPAQUE) && !PtIsDisjoint(w) ) {
|
||||
PhTile_t *tile = PhGetTile( );
|
||||
if( !tile ) return NULL;
|
||||
|
||||
|
|
|
@ -136,7 +136,6 @@ protected:
|
|||
static int EvInfo( PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo );
|
||||
static int WindowWMHandler( PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo );
|
||||
PRBool HandleEvent( PtWidget_t *widget, PtCallbackInfo_t* aCbInfo );
|
||||
PhTile_t *GetWindowClipping( );
|
||||
|
||||
void ResizeHoldOff();
|
||||
void RemoveResizeWidget();
|
||||
|
|
Загрузка…
Ссылка в новой задаче