コード例 #1
0
void
AccessibleCaretEventHub::AsyncPanZoomStopped()
{
  if (!mInitialized) {
    return;
  }

  AC_LOG("%s, state: %s", __FUNCTION__, mState->Name());
  mState->OnScrollEnd(this);
}
コード例 #2
0
void
AccessibleCaretEventHub::NotifyBlur(bool aIsLeavingDocument)
{
  if (!mInitialized) {
    return;
  }

  AC_LOG("%s, state: %s", __FUNCTION__, mState->Name());
  mState->OnBlur(this, aIsLeavingDocument);
}
コード例 #3
0
void
AccessibleCaretEventHub::ScrollPositionChanged()
{
  if (!mInitialized) {
    return;
  }

  AC_LOG("%s, state: %s", __FUNCTION__, mState->Name());
  mState->OnScrollPositionChanged(this);
}
コード例 #4
0
void
AccessibleCaretEventHub::SetState(State* aState)
{
  MOZ_ASSERT(aState);

  AC_LOG("%s -> %s", mState->Name(), aState->Name());

  mState->Leave(this);
  mState = aState;
  mState->Enter(this);
}
コード例 #5
0
void
AccessibleCaretEventHub::NotifyBlur(bool aIsLeavingDocument)
{
  if (!mInitialized) {
    return;
  }

  MOZ_ASSERT(mRefCnt.get() > 1, "Expect caller holds us as well!");

  AC_LOG("%s, state: %s", __FUNCTION__, mState->Name());
  mState->OnBlur(this, aIsLeavingDocument);
}
コード例 #6
0
void
AccessibleCaretEventHub::ScrollPositionChanged()
{
  if (!mInitialized) {
    return;
  }

  MOZ_ASSERT(mRefCnt.get() > 1, "Expect caller holds us as well!");

  AC_LOG("%s, state: %s", __FUNCTION__, mState->Name());
  mState->OnScrollPositionChanged(this);
}
コード例 #7
0
NS_IMETHODIMP
AccessibleCaretEventHub::Reflow(DOMHighResTimeStamp aStart,
                                DOMHighResTimeStamp aEnd)
{
  if (!mInitialized) {
    return NS_OK;
  }

  AC_LOG("%s, state: %s", __FUNCTION__, mState->Name());
  mState->OnReflow(this);
  return NS_OK;
}
コード例 #8
0
nsresult
AccessibleCaretEventHub::NotifySelectionChanged(nsIDOMDocument* aDoc,
                                                nsISelection* aSel,
                                                int16_t aReason)
{
  if (!mInitialized) {
    return NS_OK;
  }

  AC_LOG("%s, state: %s, reason: %d", __FUNCTION__, mState->Name(), aReason);
  mState->OnSelectionChanged(this, aDoc, aSel, aReason);
  return NS_OK;
}
コード例 #9
0
NS_IMETHODIMP
AccessibleCaretEventHub::Reflow(DOMHighResTimeStamp aStart,
                                DOMHighResTimeStamp aEnd)
{
  if (!mInitialized) {
    return NS_OK;
  }

  MOZ_ASSERT(mRefCnt.get() > 1, "Expect caller holds us as well!");

  AC_LOG("%s, state: %s", __FUNCTION__, mState->Name());
  mState->OnReflow(this);
  return NS_OK;
}
コード例 #10
0
nsresult
AccessibleCaretEventHub::NotifySelectionChanged(nsIDOMDocument* aDoc,
                                                nsISelection* aSel,
                                                int16_t aReason)
{
  if (!mInitialized) {
    return NS_OK;
  }

  MOZ_ASSERT(mRefCnt.get() > 1, "Expect caller holds us as well!");

  AC_LOG("%s, state: %s, reason: %d", __FUNCTION__, mState->Name(), aReason);
  mState->OnSelectionChanged(this, aDoc, aSel, aReason);
  return NS_OK;
}
コード例 #11
0
nsEventStatus
AccessibleCaretEventHub::HandleTouchEvent(WidgetTouchEvent* aEvent)
{
  if (aEvent->mTouches.IsEmpty()) {
    AC_LOG("%s: Receive a touch event without any touch data!", __FUNCTION__);
    return nsEventStatus_eIgnore;
  }

  nsEventStatus rv = nsEventStatus_eIgnore;

  int32_t id =
    (mActiveTouchId == kInvalidTouchId ? aEvent->mTouches[0]->Identifier()
                                       : mActiveTouchId);
  nsPoint point = GetTouchEventPosition(aEvent, id);

  mManager->SetLastInputSource(nsIDOMMouseEvent::MOZ_SOURCE_TOUCH);

  switch (aEvent->mMessage) {
    case eTouchStart:
      AC_LOGV("Before eTouchStart, state: %s", mState->Name());
      rv = mState->OnPress(this, point, id, eTouchEventClass);
      AC_LOGV("After eTouchStart, state: %s, consume: %d", mState->Name(), rv);
      break;

    case eTouchMove:
      AC_LOGV("Before eTouchMove, state: %s", mState->Name());
      rv = mState->OnMove(this, point);
      AC_LOGV("After eTouchMove, state: %s, consume: %d", mState->Name(), rv);
      break;

    case eTouchEnd:
      AC_LOGV("Before eTouchEnd, state: %s", mState->Name());
      rv = mState->OnRelease(this);
      AC_LOGV("After eTouchEnd, state: %s, consume: %d", mState->Name(), rv);
      break;

    case eTouchCancel:
      AC_LOGV("Got eTouchCancel, state: %s", mState->Name());
      // Do nothing since we don't really care eTouchCancel anyway.
      break;

    default:
      break;
  }

  return rv;
}
コード例 #12
0
void
AccessibleCaret::SetSelectionBarElementStyle(const nsRect& aRect)
{
  int32_t height = nsPresContext::AppUnitsToIntCSSPixels(aRect.height);
  nsAutoString barStyleStr;
  barStyleStr.AppendPrintf("margin-top: -%dpx; height: %dpx;",
                           height, height);

  float zoomLevel = GetZoomLevel();
  barStyleStr.AppendPrintf(" width: %.2fpx;", sBarWidth / zoomLevel);

  ErrorResult rv;
  SelectionBarElement()->SetAttribute(NS_LITERAL_STRING("style"), barStyleStr, rv);
  MOZ_ASSERT(!rv.Failed());

  AC_LOG("Set bar style: %s", NS_ConvertUTF16toUTF8(barStyleStr).get());
}
コード例 #13
0
void
AccessibleCaret::SetCaretElementStyle(const nsRect& aRect)
{
  nsPoint position = CaretElementPosition(aRect);
  nsAutoString styleStr;
  styleStr.AppendPrintf("left: %dpx; top: %dpx;",
                        nsPresContext::AppUnitsToIntCSSPixels(position.x),
                        nsPresContext::AppUnitsToIntCSSPixels(position.y));

  float zoomLevel = GetZoomLevel();
  styleStr.AppendPrintf(" width: %.2fpx; height: %.2fpx; margin-left: %.2fpx",
                        sWidth / zoomLevel,
                        sHeight / zoomLevel,
                        sMarginLeft / zoomLevel);

  ErrorResult rv;
  CaretElement()->SetAttribute(NS_LITERAL_STRING("style"), styleStr, rv);
  MOZ_ASSERT(!rv.Failed());

  AC_LOG("Set caret style: %s", NS_ConvertUTF16toUTF8(styleStr).get());
}
コード例 #14
0
ファイル: Alpha.cpp プロジェクト: JDHDEV/AlphaEngine
//===================================================================
// Win32 Specific Stuff
//
// InitInstance - this checks system resources, creates your window, and launches the game
//
// preprocessor macro setting in the C++ options of the project provides the base macro
// C preprocessor string concatenation takes care of the rest.
//
// AlphaApp::InitInstance - Chapter 5, page 136
//
//===================================================================
bool AlphaApp::InitInstance(HINSTANCE hInstance, LPWSTR lpCmdLine, HWND hWnd, int screenWidth, int screenHeight, bool windowed)
{	
	AC_LOG("Script","Init");
	// Check for existing instance of the same window - Chapter 5, page 137
    // 
#ifndef _DEBUG
    // Note - it can be really useful to debug network code to have
    // more than one instance of the game up at one time - so
    // feel free to comment these lines in or out as you wish!
    if (!IsOnlyInstance(VGetGameTitle()))
		return false;

#endif

	// We don't need a mouse cursor by default, let the game turn it on
	SetCursor(NULL);

	// Check for adequate machine resources.
	// Check secondary storage space and memory. - Chapter 5, page 138-139
	// Calculate the CPU speed. - Chapter 5, page 140
	bool resourceCheck = false;
	while (!resourceCheck)
	{
		const DWORDLONG physicalRAM = 512 * MEGABYTE;
		const DWORDLONG virtualRAM = 1024 * MEGABYTE;
		const DWORDLONG diskSpace = 10 * MEGABYTE;
		if (!CheckStorage(diskSpace))
			return false;

		const DWORD minCpuSpeed = 1300;     // 1.3Ghz
		DWORD thisCPU = ReadCPUSpeed();
		if (thisCPU < minCpuSpeed)
		{
			AC_ERROR("GetCPUSpeed reports CPU is too slow for this game.");
			return false;
		}

		resourceCheck = true;
	}

	m_hInstance = hInstance;

    // register all events
    RegisterEngineEvents();
    VRegisterGameEvents();

	//
	// Initialize the ResCache - Chapter 5, page 141
	//
	//    Note - this is a little different from the book. Here we have a speccial resource ZIP file class, DevelopmentResourceZipFile,
	//    that actually reads directly from the source asset files, rather than the ZIP file. This is MUCH better during development, since
	//    you don't want to have to rebuild the ZIP file every time you make a minor change to an asset.
	//
	IResourceFile *zipFile = (m_bIsEditorRunning || m_Options.m_useDevelopmentDirectories) ? 
		AC_NEW DevelopmentResourceZipFile(L"Assets.zip", DevelopmentResourceZipFile::Editor) :
		AC_NEW ResourceZipFile(L"Assets.zip");

	m_ResCache = AC_NEW ResCache(50, zipFile);

	if (!m_ResCache->Init())
	{
        AC_ERROR("Failed to initialize resource cache!  Are your paths set up correctly?");
		return false;
	}
	
	//extern shared_ptr<IResourceLoader> CreateWAVResourceLoader();
	//extern shared_ptr<IResourceLoader> CreateOGGResourceLoader();
	extern shared_ptr<IResourceLoader> CreateDDSResourceLoader();
	extern shared_ptr<IResourceLoader> CreateJPGResourceLoader();
    extern shared_ptr<IResourceLoader> CreateXmlResourceLoader();
    //extern shared_ptr<IResourceLoader> CreateSdkMeshResourceLoader();
    extern shared_ptr<IResourceLoader> CreateScriptResourceLoader();

	// Note - register these in order from least specific to most specific! They get pushed onto a list.
	// RegisterLoader is discussed in Chapter 5, page 142
	//m_ResCache->RegisterLoader(CreateWAVResourceLoader());
	//m_ResCache->RegisterLoader(CreateOGGResourceLoader());
	m_ResCache->RegisterLoader(CreateDDSResourceLoader());
	m_ResCache->RegisterLoader(CreateJPGResourceLoader());
    m_ResCache->RegisterLoader(CreateXmlResourceLoader());
	//m_ResCache->RegisterLoader(CreateSdkMeshResourceLoader());
    m_ResCache->RegisterLoader(CreateScriptResourceLoader());

	//// Load strings that will be presented to the player. - Chapter 5, page 142
	//if(!LoadStrings("English"))
	//{
 //       AC_ERROR("Failed to load strings");
	//	return false;
	//}

	// Create the LUA script manager. - Chapter 5, page 144
	if (!LuaStateManager::Create())
	{
		AC_ERROR("Failed to initialize Lua");
		return false;
	}

	// Load the preinit file.  This is within braces to create a scope and destroy the resource once it's loaded.  We
    // don't need to do anything with it, we just need to load it.
    {
        Resource resource(SCRIPT_PREINIT_FILE);
        shared_ptr<ResHandle> pResourceHandle = m_ResCache->GetHandle(&resource);  // this actually loads the XML file from the zip file
    }

    // Register function exported from C++
    ScriptExports::Register();
    ScriptProcess::RegisterScriptClass();
    BaseScriptComponent::RegisterScriptFunctions();

	// Create the game's event manager. - Chapter 5, page 145
	m_pEventManager = AC_NEW EventManager("AlphaApp Event Mgr", true);
	if (!m_pEventManager)
	{
		AC_ERROR("Failed to create EventManager.");
		return false;
	}

	// Inititalize DirectX, the application's window, and the D3D device. - Chapter 5, page 145
	//DXUTInit(true, true, lpCmdLine, true);
	//Init DirectX11Wrapper class
	g_pDX11W->DX11WInit(lpCmdLine);// may need to be put in the alpha app init instance function

	if (hWnd==NULL)
	{
		//DXUTCreateWindow(VGetGameTitle(), hInstance, VGetIcon());
		g_pDX11W->DX11WCreateWindow(VGetGameTitle(), hInstance, VGetIcon());
	}
	else
	{
	    //DXUTSetWindow( hWnd, hWnd, hWnd );
	}

	if(!GetHwnd())
	{
		return false;
	}
	SetWindowText(GetHwnd(), VGetGameTitle());
	
	// initialize the directory location you can store save game files
	//_tcscpy_s(m_saveGameDirectory, GetSaveGameDirectory(GetHwnd(), VGetGameAppDirectory()));

    // DXUTCreateDevice - Chapter 5 - page 139
    m_screenSize = Point(screenWidth, screenHeight);

	//DXUTCreateDevice( D3D_FEATURE_LEVEL_10_1, true, screenWidth, screenHeight);
	g_pDX11W->DX11WCreateDevice(windowed, screenWidth, screenHeight);

	m_Renderer = shared_ptr<IRenderer>(AC_NEW D3DRenderer11());
    m_Renderer->VSetBackgroundColor(0, 50, 100, 255);
    m_Renderer->VOnRestore();

	// You usually must have an HWND to initialize your game views...
	//    VCreateGameAndView			- Chapter 5, page 145
	m_pGame = VCreateGameAndView();
	if (!m_pGame)
		return false;

	// now that all the major systems are initialized, preload resources 
	//    Preload calls are discussed in Chapter 5, page 148
	//m_ResCache->Preload("*.ogg", NULL);
	m_ResCache->Preload("*.dds", NULL);
	//m_ResCache->Preload("*.jpg", NULL);

	//if ( GameCodeApp::GetRendererImpl() == GameCodeApp::Renderer_D3D11 )
	//	m_ResCache->Preload("*.sdkmesh", NULL);

	m_bIsRunning = TRUE;

	return TRUE;
}