예제 #1
0
void AwtDesktopProperties::GetXPStyleProperties() {
    LPTSTR value;

    value = getXPStylePropFromReg(TEXT("ThemeActive"));
    try {
        SetBooleanProperty(TEXT("win.xpstyle.themeActive"), (value != NULL && *value == _T('1')));
        if (value != NULL) {
            free(value);
            value = NULL;
        }
        value = getXPStylePropFromReg(TEXT("DllName"));
        if (value != NULL) {
            SetStringProperty(TEXT("win.xpstyle.dllName"), value);
            free(value);
            value = NULL;
        }
        value = getXPStylePropFromReg(TEXT("SizeName"));
        if (value != NULL) {
            SetStringProperty(TEXT("win.xpstyle.sizeName"), value);
            free(value);
            value = NULL;
        }
        value = getXPStylePropFromReg(TEXT("ColorName"));
        if (value != NULL) {
            SetStringProperty(TEXT("win.xpstyle.colorName"), value);
            free(value);
        }
    }
    catch (std::bad_alloc&) {
        if (value != NULL) {
            free(value);
        }
        throw;
    }
}
예제 #2
0
void AwtDesktopProperties::GetIconParameters() {
    //
    // icon properties
    //
    ICONMETRICS	iconmetrics;

    iconmetrics.cbSize = sizeof(iconmetrics);
    VERIFY( SystemParametersInfo(SPI_GETICONMETRICS, iconmetrics.cbSize, &iconmetrics, FALSE) );

    SetIntegerProperty(TEXT("win.icon.hspacing"), iconmetrics.iHorzSpacing);
    SetIntegerProperty(TEXT("win.icon.vspacing"), iconmetrics.iVertSpacing);
    SetBooleanProperty(TEXT("win.icon.titleWrappingOn"), iconmetrics.iTitleWrap != 0);
    SetFontProperty(TEXT("win.icon.font"), iconmetrics.lfFont);
}
예제 #3
0
void AwtDesktopProperties::GetOtherParameters() {
    // TODO BEGIN: On NT4, some setttings don't trigger WM_SETTINGCHANGE --
    // check whether this has been fixed on Windows 2000 and Windows 98
    // ECH 10/6/2000 seems to be fixed on NT4 SP5, but not on 98
    SetBooleanProperty(TEXT("win.frame.fullWindowDragsOn"), GetBooleanParameter(SPI_GETDRAGFULLWINDOWS));
    SetBooleanProperty(TEXT("win.text.fontSmoothingOn"), GetBooleanParameter(SPI_GETFONTSMOOTHING));
    // TODO END

    if (IS_WINXP) {
        SetIntegerProperty(TEXT("win.text.fontSmoothingType"), 
                           GetIntegerParameter(SPI_GETFONTSMOOTHINGTYPE));
        SetIntegerProperty(TEXT("win.text.fontSmoothingContrast"), 
                           GetIntegerParameter(SPI_GETFONTSMOOTHINGCONTRAST));
        SetIntegerProperty(TEXT("win.text.fontSmoothingOrientation"),
                           GetLCDSubPixelOrder());
    }

    int cxdrag = GetSystemMetrics(SM_CXDRAG);
    int cydrag = GetSystemMetrics(SM_CYDRAG);
    SetIntegerProperty(TEXT("win.drag.width"), cxdrag);
    SetIntegerProperty(TEXT("win.drag.height"), cydrag);
    SetIntegerProperty(TEXT("DnD.gestureMotionThreshold"), max(cxdrag, cydrag)/2);
    SetIntegerProperty(TEXT("awt.mouse.numButtons"), GetSystemMetrics(SM_CMOUSEBUTTONS));
    SetIntegerProperty(TEXT("awt.multiClickInterval"), GetDoubleClickTime());

    // BEGIN cross-platform properties
    // Note that these are cross-platform properties, but are being stuck into
    // WDesktopProperties.  WToolkit.lazilyLoadDesktopProperty() can find them,
    // but if a Toolkit subclass uses the desktopProperties
    // member, these properties won't be there. -bchristi, echawkes
    // This property is called "win.frame.fullWindowDragsOn" above
    // This is one of the properties that don't trigger WM_SETTINGCHANGE
    SetBooleanProperty(TEXT("awt.dynamicLayoutSupported"), GetBooleanParameter(SPI_GETDRAGFULLWINDOWS));

    // 95 MouseWheel support
    // More or less copied from the MSH_MOUSEWHEEL MSDN entry
    if (IS_WIN95 && !IS_WIN98) {
        HWND hdlMSHWHEEL = NULL;
        UINT msgMSHWheelSupported = NULL;
        BOOL wheelSupported = FALSE;

        msgMSHWheelSupported = RegisterWindowMessage(MSH_WHEELSUPPORT);
        hdlMSHWHEEL = FindWindow(MSH_WHEELMODULE_CLASS, MSH_WHEELMODULE_TITLE);
        if (hdlMSHWHEEL && msgMSHWheelSupported) {
            wheelSupported = (BOOL)::SendMessage(hdlMSHWHEEL,
                                                 msgMSHWheelSupported, 0, 0);
        }
        SetBooleanProperty(TEXT("awt.wheelMousePresent"), wheelSupported);
    }
    else {
        SetBooleanProperty(TEXT("awt.wheelMousePresent"),
                           ::GetSystemMetrics(SM_MOUSEWHEELPRESENT));
    }

    // END cross-platform properties

    if (IS_WIN98 || IS_WIN2000) {
      //DWORD	menuShowDelay;
        //SystemParametersInfo(SPI_GETMENUSHOWDELAY, 0, &menuShowDelay, 0);
	// SetIntegerProperty(TEXT("win.menu.showDelay"), menuShowDelay);
        SetBooleanProperty(TEXT("win.frame.captionGradientsOn"), GetBooleanParameter(SPI_GETGRADIENTCAPTIONS));
        SetBooleanProperty(TEXT("win.item.hotTrackingOn"), GetBooleanParameter(SPI_GETHOTTRACKING));
    }

    if (IS_WIN2000) {
        SetBooleanProperty(TEXT("win.menu.keyboardCuesOn"), GetBooleanParameter(SPI_GETKEYBOARDCUES));
    }

    // High contrast accessibility property
    HIGHCONTRAST contrast;
    contrast.cbSize = sizeof(HIGHCONTRAST);
    if (SystemParametersInfo(SPI_GETHIGHCONTRAST, sizeof(HIGHCONTRAST),
			     &contrast, 0) != 0 &&
	      (contrast.dwFlags & HCF_HIGHCONTRASTON) == HCF_HIGHCONTRASTON) {
      SetBooleanProperty(TEXT("win.highContrast.on"), TRUE);
    }
    else {
      SetBooleanProperty(TEXT("win.highContrast.on"), FALSE);
    }
    
    if (fn_SHGetSettings != NULL) {
        SHELLFLAGSTATE sfs;
        fn_SHGetSettings(&sfs, SSF_SHOWALLOBJECTS | SSF_SHOWATTRIBCOL);
        if (sfs.fShowAllObjects) {
            SetBooleanProperty(TEXT("awt.file.showHiddenFiles"), TRUE);
        }
        else {
            SetBooleanProperty(TEXT("awt.file.showHiddenFiles"), FALSE);
        }
        if (sfs.fShowAttribCol) {
            SetBooleanProperty(TEXT("awt.file..showAttribCol"), TRUE);
        }
        else {
            SetBooleanProperty(TEXT("awt.file.showAttribCol"), FALSE);
        }
    }

    LPTSTR value;
    DWORD valueType;

    // Shell Icon BPP - only honored on platforms before XP
    value = getWindowsPropFromReg(TEXT("Control Panel\\Desktop\\WindowMetrics"),
				  TEXT("Shell Icon BPP"), &valueType);
    if (value != NULL) {
	if (valueType == REG_SZ) {
	    SetStringProperty(TEXT("win.icon.shellIconBPP"), value);
	}
	free(value);
    }


    // The following registry settings control the file chooser places bar
    // under the Windows L&F. These settings are not present by default, but
    // can be enabled using the TweakUI tool from Microsoft. For more info,
    // see http://msdn.microsoft.com/msdnmag/issues/1100/Registry/

    // NoPlacesBar is a REG_DWORD, with values 0 or 1
    value = getWindowsPropFromReg(TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\comdlg32"),
				  TEXT("NoPlacesBar"), &valueType);
    if (value != NULL) {
	if (valueType == REG_DWORD) {
	    SetBooleanProperty(TEXT("win.comdlg.noPlacesBar"), (BOOL)((int)*value != 0));
	}
	free(value);
    }

    LPTSTR valueName = TEXT("PlaceN");
    LPTSTR valueNameBuf = (LPTSTR)safe_Malloc((lstrlen(valueName) + 1) * sizeof(TCHAR));
    lstrcpy(valueNameBuf, valueName);

    LPTSTR propKey = TEXT("win.comdlg.placesBarPlaceN");
    LPTSTR propKeyBuf = (LPTSTR)safe_Malloc((lstrlen(propKey) + 1) * sizeof(TCHAR));
    lstrcpy(propKeyBuf, propKey);

    int i = 0;
    do {
	valueNameBuf[5] = _T('0' + i++);
	propKeyBuf[25] = valueNameBuf[5];

	LPTSTR key = TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\comdlg32\\PlacesBar");
	if ((value = getWindowsPropFromReg(key, valueNameBuf, &valueType)) != NULL) {
	    if (valueType == REG_DWORD) {
		// Value is a CSIDL
		SetIntegerProperty(propKeyBuf, (int)*value);
	    } else {
		// Value is a path
		SetStringProperty(propKeyBuf, value);
	    }
	    free(value);
	}
    } while (value != NULL);

    free(valueNameBuf);
    free(propKeyBuf);
}
static bool
SetOperator(OperatorData*   aOperatorData,
            nsOperatorFlags aForm,
            const nsCString& aOperator,
            nsString&        aAttributes)

{
  static const char16_t kNullCh = char16_t('\0');

  // aOperator is in the expanded format \uNNNN\uNNNN ...
  // First compress these Unicode points to the internal nsString format
  int32_t i = 0;
  nsAutoString name, value;
  int32_t len = aOperator.Length();
  char16_t c = aOperator[i++];
  uint32_t state  = 0;
  char16_t uchar = 0;
  while (i <= len) {
    if (0 == state) {
      if (c != '\\')
        return false;
      if (i < len)
        c = aOperator[i];
      i++;
      if (('u' != c) && ('U' != c))
        return false;
      if (i < len)
        c = aOperator[i];
      i++;
      state++;
    }
    else {
      if (('0' <= c) && (c <= '9'))
         uchar = (uchar << 4) | (c - '0');
      else if (('a' <= c) && (c <= 'f'))
         uchar = (uchar << 4) | (c - 'a' + 0x0a);
      else if (('A' <= c) && (c <= 'F'))
         uchar = (uchar << 4) | (c - 'A' + 0x0a);
      else return false;
      if (i < len)
        c = aOperator[i];
      i++;
      state++;
      if (5 == state) {
        value.Append(uchar);
        uchar = 0;
        state = 0;
      }
    }
  }
  if (0 != state) return false;

  // Quick return when the caller doesn't care about the attributes and just wants
  // to know if this is a valid operator (this is the case at the first pass of the
  // parsing of the dictionary in InitOperators())
  if (!aForm) return true;

  // Add operator to hash table
  aOperatorData->mFlags |= aForm;
  aOperatorData->mStr.Assign(value);
  value.AppendInt(aForm, 10);
  gOperatorTable->Put(value, aOperatorData);

#ifdef DEBUG
  NS_LossyConvertUTF16toASCII str(aAttributes);
#endif
  // Loop over the space-delimited list of attributes to get the name:value pairs
  aAttributes.Append(kNullCh);  // put an extra null at the end
  char16_t* start = aAttributes.BeginWriting();
  char16_t* end   = start;
  while ((kNullCh != *start) && (kDashCh != *start)) {
    name.SetLength(0);
    value.SetLength(0);
    // skip leading space, the dash amounts to the end of the line
    while ((kNullCh!=*start) && (kDashCh!=*start) && nsCRT::IsAsciiSpace(*start)) {
      ++start;
    }
    end = start;
    // look for ':'
    while ((kNullCh!=*end) && (kDashCh!=*end) && !nsCRT::IsAsciiSpace(*end) &&
           (kColonCh!=*end)) {
      ++end;
    }
    // If ':' is not found, then it's a boolean property
    bool IsBooleanProperty = (kColonCh != *end);
    *end = kNullCh; // end segment here
    // this segment is the name
    if (start < end) {
      name.Assign(start);
    }
    if (IsBooleanProperty) {
      SetBooleanProperty(aOperatorData, name);
    } else {
      start = ++end;
      // look for space or end of line
      while ((kNullCh!=*end) && (kDashCh!=*end) &&
             !nsCRT::IsAsciiSpace(*end)) {
        ++end;
      }
      *end = kNullCh; // end segment here
      if (start < end) {
        // this segment is the value
        value.Assign(start);
      }
      SetProperty(aOperatorData, name, value);
    }
    start = ++end;
  }
  return true;
}
MediaFoundationTransform::MediaFoundationTransform(IMFActivate *activationObj, WmaEncodingFormat encodingFormat)
{
	UINT32 nameLen;

	// Transform name is an MFActivate object property, so get that first

	activationObj->GetString(MFT_FRIENDLY_NAME_Attribute, _transformName, sizeof(_transformName), &nameLen);

	HRESULT hr = activationObj->ActivateObject(IID_PPV_ARGS(&_mfEncoder));

	hr = _mfEncoder->QueryInterface(IID_PPV_ARGS(&_propertyStore));

	// Configure the tranform to perform the requested compression format

	switch (encodingFormat)
	{
	case WmaEncodingFormat::Lossless:
		SetBooleanProperty(MFPKEY_VBRENABLED, true);
		SetBooleanProperty(MFPKEY_CONSTRAIN_ENUMERATED_VBRQUALITY, true);
		SetUint32Property(MFPKEY_DESIRED_VBRQUALITY, 100);
		break;

	case WmaEncodingFormat::Quality_10:
		SetBooleanProperty(MFPKEY_VBRENABLED, true);
		SetBooleanProperty(MFPKEY_CONSTRAIN_ENUMERATED_VBRQUALITY, true);
		SetUint32Property(MFPKEY_DESIRED_VBRQUALITY, 10);
		break;

	case WmaEncodingFormat::Quality_25:
		SetBooleanProperty(MFPKEY_VBRENABLED, true);
		SetBooleanProperty(MFPKEY_CONSTRAIN_ENUMERATED_VBRQUALITY, true);
		SetUint32Property(MFPKEY_DESIRED_VBRQUALITY, 25);
		break;

	case WmaEncodingFormat::Quality_50:
		SetBooleanProperty(MFPKEY_VBRENABLED, true);
		SetBooleanProperty(MFPKEY_CONSTRAIN_ENUMERATED_VBRQUALITY, true);
		SetUint32Property(MFPKEY_DESIRED_VBRQUALITY, 50);
		break;

	case WmaEncodingFormat::Quality_75:
		SetBooleanProperty(MFPKEY_VBRENABLED, true);
		SetBooleanProperty(MFPKEY_CONSTRAIN_ENUMERATED_VBRQUALITY, true);
		SetUint32Property(MFPKEY_DESIRED_VBRQUALITY, 75);
		break;

	case WmaEncodingFormat::Quality_90:
		SetBooleanProperty(MFPKEY_VBRENABLED, true);
		SetBooleanProperty(MFPKEY_CONSTRAIN_ENUMERATED_VBRQUALITY, true);
		SetUint32Property(MFPKEY_DESIRED_VBRQUALITY, 90);
		break;

	case WmaEncodingFormat::Quality_98:
		SetBooleanProperty(MFPKEY_VBRENABLED, true);
		SetBooleanProperty(MFPKEY_CONSTRAIN_ENUMERATED_VBRQUALITY, true);
		SetUint32Property(MFPKEY_DESIRED_VBRQUALITY, 98);
		break;

	}

	hr = _propertyStore->Commit();

	// enumerate output types and try to find the appropriate one for our purposes

	DWORD index = 0;

	while (true)
	{
		IMFMediaType *mediaType;

		hr = _mfEncoder->GetOutputAvailableType(0, index++, &mediaType);

		if (hr == MF_E_NO_MORE_TYPES)
			break;

		// Get the AM_MEDIA_TYPE structure from the media type, in case we want to need
		// to differentiate between Standard and Pro WMA codecs in the future...

		AM_MEDIA_TYPE *amMediaType;
	    mediaType->GetRepresentation(AM_MEDIA_TYPE_REPRESENTATION, (LPVOID *) &amMediaType);
	    WAVEFORMATEX *waveFormat = (WAVEFORMATEX *) amMediaType->pbFormat;

		// there's only a few things we're interested in with the output type, so only bother grabbing those values

		UINT32 channelCount;
		UINT32 samplesPerSecond;
		UINT32 bitsPerSample;

		hr = mediaType->GetUINT32(MF_MT_AUDIO_NUM_CHANNELS, &channelCount);
		hr = mediaType->GetUINT32(MF_MT_AUDIO_SAMPLES_PER_SECOND, &samplesPerSecond);
		hr = mediaType->GetUINT32(MF_MT_AUDIO_BITS_PER_SAMPLE, &bitsPerSample);

		if ((channelCount == 2) && (bitsPerSample == 16) && (samplesPerSecond == 44100))
		{
			_mfMediaType = mediaType;

//			IMFActivate *areYouFuckingSerious;
//			activationObj->ShutdownObject();
	//		_mfEncoder->Release();

//			hr = MFCreateWMAEncoderActivate(mediaType, _propertyStore, &areYouFuckingSerious);

		
	//		hr = areYouFuckingSerious->ActivateObject(IID_PPV_ARGS(&_mfEncoder));

			break;
		}
	}

  index = 0;
}