void doRender(Renderer::RenderContext& renderContext) {
                const Model::BrushFace* face = m_helper.face();
                const Mat4x4 fromFace = face->fromTexCoordSystemMatrix(Vec2f::Null, Vec2f::One, true);
                
                const Plane3& boundary = face->boundary();
                const Mat4x4 toPlane = planeProjectionMatrix(boundary.distance, boundary.normal);
                const Mat4x4 fromPlane = invertedMatrix(toPlane);

                const Vec2f originPosition(toPlane * fromFace * Vec3(m_helper.originInFaceCoords()));
                const Vec2f faceCenterPosition(toPlane * m_helper.face()->boundsCenter());

                const Color& handleColor = pref(Preferences::HandleColor);
                const Color& highlightColor = pref(Preferences::SelectedHandleColor);

                Renderer::ActiveShader shader(renderContext.shaderManager(), Renderer::Shaders::VaryingPUniformCShader);
                const Renderer::MultiplyModelMatrix toWorldTransform(renderContext.transformation(), fromPlane);
                {
                    const Mat4x4 translation = translationMatrix(Vec3(originPosition));
                    const Renderer::MultiplyModelMatrix centerTransform(renderContext.transformation(), translation);
                    if (m_highlight)
                        shader.set("Color", highlightColor);
                    else
                        shader.set("Color", handleColor);
                    m_outer.render();
                }
                
                {
                    const Mat4x4 translation = translationMatrix(Vec3(faceCenterPosition));
                    const Renderer::MultiplyModelMatrix centerTransform(renderContext.transformation(), translation);
                    shader.set("Color", highlightColor);
                    m_center.render();
                }
            }
 void VertexHandleManager::renderHighlight(Renderer::RenderContext& renderContext, Renderer::RenderBatch& renderBatch, const Vec3& position) {
     Renderer::RenderService renderService(renderContext, renderBatch);
     renderService.setForegroundColor(pref(Preferences::SelectedHandleColor));
     renderService.renderPointHandleHighlight(position);
     
     renderService.setForegroundColor(pref(Preferences::SelectedInfoOverlayTextColor));
     renderService.setBackgroundColor(pref(Preferences::SelectedInfoOverlayBackgroundColor));
     renderService.renderString(position.asString(), position);
 }
Exemple #3
0
int main() {
  
  //tam de columnas y columnas de las matrices de hombres y mujeres
  int columnas = 4;
  
  //matriz de preferencias de hombres y mujeres
  std::vector<std::vector<int>> pref(2 * columnas, std::vector<int>(columnas));
  
  //se llena la matriz con las preferencias
  pref =
  {
    //hombres
    { 4, 5, 6, 7 }, //hombre 0
    { 5, 6, 7, 4 }, //hombre 1
    { 6, 7, 4, 5 }, //hombre 2
    { 7, 4, 5, 6 }, //hombre 3
    
    //mujeres
    { 0, 1, 2, 3 }, //mujer 4
    { 1, 2, 3, 0 }, //mujer 5
    { 2, 3, 0, 1 }, //mujer 6
    { 3, 0, 1, 2 }, //mujer 7
    
  };
  
  asignarParejas(pref, columnas);
  
}//cierre del main
Exemple #4
0
//Event de double click
void GameButton::mouseDoubleClickEvent(QMouseEvent* e)
{
    e->accept();

    bool lauchGame(true); //Représente si le jeu peut être lancé ou non

    if(pwd) //Si verif de mdp alors verif de mdp
        lauchGame = SplashScreen::verifPwd();

    //Si le jeu peut être lancé
    if(lauchGame)
    {
        QLogger::QLog_Info("game", "Info : Tentative de lancement : " + path);

        //Si on réussis à relacher le clavier
        if(unhookKB())
        {
            //On update certaine stats
            QSettings* pref(new QSettings("stats/" + nom + ".ini", QSettings::IniFormat));

            int val(pref->value("launch", QVariant(0)).toInt());
            pref->setValue("launch", QVariant(val+1));
            delete pref;


            //Si c'est un jeu steam, on va chercher l'exe steam qu'on lance avec certain arguments
            if(steam)
                proc->start(QSettings("pref.ini", QSettings::IniFormat).value("steamPath").toString(), QStringList() << "-applaunch" << gameID);
            else //Sinon on lance le jeu tout simplement
                proc->start(path);
        }
        else
            QMessageBox::warning(0, "Erreur", "Le système refuse de relâcher la capture clavier");
    }
}
nsresult nsStatusBarBiffManager::Init()
{
  if (mInitialized)
    return NS_ERROR_ALREADY_INITIALIZED;

  nsresult rv;

  kBiffStateAtom = MsgNewAtom("BiffState").get();

  nsCOMPtr<nsIMsgMailSession> mailSession = 
    do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv); 
  if(NS_SUCCEEDED(rv))
    mailSession->AddFolderListener(this, nsIFolderListener::intPropertyChanged);

  nsCOMPtr<nsIPrefBranch> pref(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
  NS_ENSURE_SUCCESS(rv, rv);

  bool chatEnabled = false;
  if (NS_SUCCEEDED(rv))
    rv = pref->GetBoolPref(PREF_CHAT_ENABLED, &chatEnabled);
  if (NS_SUCCEEDED(rv) && chatEnabled) {
    nsCOMPtr<nsIObserverService> observerService =
      mozilla::services::GetObserverService();
    if (observerService)
      observerService->AddObserver(this, NEW_CHAT_MESSAGE_TOPIC, false);
  }

  mInitialized = true;
  return NS_OK;
}
NS_IMETHODIMP
nsStatusBarBiffManager::OnItemIntPropertyChanged(nsIMsgFolder *item, nsIAtom *property, int32_t oldValue, int32_t newValue)
{
  if (kBiffStateAtom == property && mCurrentBiffState != newValue) {
    // if we got new mail, attempt to play a sound.
    // if we fail along the way, don't return.
    // we still need to update the UI.    
    if (newValue == nsIMsgFolder::nsMsgBiffState_NewMail) {
      nsresult rv;
      nsCOMPtr<nsIPrefBranch> pref(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
      NS_ENSURE_SUCCESS(rv, rv);
      bool playSoundOnBiff = false;
      rv = pref->GetBoolPref(PREF_PLAY_SOUND_ON_NEW_MAIL, &playSoundOnBiff);
      NS_ENSURE_SUCCESS(rv, rv);
      if (playSoundOnBiff) {
        // if we fail to play the biff sound, keep going.
        (void)PlayBiffSound();
      }
    }
    mCurrentBiffState = newValue;

    // don't care if notification fails
    nsCOMPtr<nsIObserverService> observerService =
      mozilla::services::GetObserverService();
      
    if (observerService)
      observerService->NotifyObservers(static_cast<nsIStatusBarBiffManager*>(this), "mail:biff-state-changed", nullptr);
  }
  return NS_OK;
}
Exemple #7
0
bool FUNCDISTANCE::execute(void)
{
	bool result= false;
	VMREGTYPE target= 0;
	VMFLOAT distance= 0;
	VMPTR<TES3REFERENCE*> pref(machine);
	VMPTR<TES3REFERENCE> thisref(machine);
	VMPTR<TES3REFERENCE> targetref(machine);
	
	try
	{
		if(machine.pop(target))
		{
			pref= (TES3REFERENCE**)reltolinear(SCRIPTTARGETREF_IMAGE);
			thisref= *pref;
			targetref= (TES3REFERENCE*)target;
			FLOAT dx= targetref->x - thisref->x;
			FLOAT dy= targetref->y - thisref->y;
			FLOAT dz= targetref->z - thisref->z;
			distance= sqrt(dx*dx+dy*dy+dz*dz);
			result= machine.push(distance);
		}
	}
	catch(...)
	{
		result= false;
	}
			
	return result;
}
bool FUNCREFID::execute(void)
{
	bool result= false;
	VMPTR<TES3REFERENCE*> pref(machine);
	VMPTR<TES3REFERENCE> ref(machine);
	VMPTR<TES3TEMPLATE> templ(machine);
	VMPTR<TES3IDSTRING> id(machine);
	const char* idstring= "null";
	try
	{
		pref= (TES3REFERENCE**)reltolinear(SCRIPTTARGETREF_IMAGE);
		ref= *pref;
		templ= ref->templ;
		id= (VPIDSTRING)templ->objectid;
		idstring= strings.add((const char*)id->id);
		result= machine.push((VMREGTYPE)idstring);
	}
	catch(...)
	{
		result= false;
	}
	
		
	return result;
}
Exemple #9
0
void output()
{
  ConnectionList& cl(gConnectionList);
  if(!cl.empty()) {
    ConnectionMap::iterator it = cl.getBeginUnlocked();
    mux_t mux = it->first;
    ConnectionParam& conn(it->second);
    std::cout << "Client " << mux << ": " ;
    if(conn.remote_end_==PacketSourceEndpoint()) {
      std::cout<< "not registered";
    } else {
      std::cout<< conn.remote_end_;
    }
    std::cout << std::endl;
    //std::cout << "Connection: Keyderivation-Type: " << conn.kd_.printType() << std::endl;
    cl.clear();
  } else {
    network_address_type_t types[] = {ipv4,ipv6,ethernet};
    for(int types_idx=0; types_idx<3; types_idx++) {
      network_address_type_t type = types[types_idx];
      if(!gRoutingTable.empty(type)) {
        RoutingMap::iterator it = gRoutingTable.getBeginUnlocked(type);
        NetworkPrefix pref(it->first);
        std::cout << "Route: " << pref.toString() << "/" << (int)pref.getNetworkPrefixLength() << " -> ";
        mux_t mux = it->second;
        std::cout << mux << std::endl;
        gRoutingTable.clear(type);
      }
    }
  }
}
QFont Highlighter::readFontSettings()
{
    QSettings pref( "Castano Inc", "QShaderEdit" );

    pref.beginGroup("CodeEditor");

    QString name;
    int size=0;

    #if defined(Q_OS_DARWIN)
        name = pref.value("font","Monaco").toString();
        size = pref.value("size",11).toInt();
    #elif defined(Q_OS_WIN32)
        name = pref.value("font","Courier").toString();
        size = pref.value("size",8).toInt();
    #else
        name = pref.value("font","Monospace").toString();
        size = pref.value("size",8).toInt();
    #endif

    QFont m_font;// = QApplication::font();
    m_font.setFamily(name);
    m_font.setPointSize(size);
    m_font.setFixedPitch(true);

    pref.endGroup();

    return m_font;
}
Exemple #11
0
int main() {
#ifdef ssu1
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  int n;
  scanf("%d", &n);
  std::vector<int> a, x(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &x[i]);
  }
  std::sort(x.begin(), x.end());
  for (int i = 0; i + 1 < n; ++i) {
    a.push_back(x[i + 1] - x[i]);
  }
  int cnt = (n - 2) / 2 + (n % 2);
  std::vector<int> pref(a.size() + 1);
  for (int i = 1; i < pref.size(); ++i) {
    pref[i] = pref[i - 1] + a[i - 1];
  }
  int sumsuf = 0, ans = 0;
  for (int cntsuf = 0; cntsuf <= cnt; ++cntsuf) {
    if (cntsuf > 0) {
      sumsuf += a[a.size() - cntsuf];
    }
    ans = std::max(ans, sumsuf + pref[cnt - cntsuf]);
  }
  printf("%d\n", pref.back() - ans);
  return 0;
}
Exemple #12
0
void CodeGen::genCodeForTreeFloat(GenTreePtr tree,
                                  regMaskTP  needReg,
                                  regMaskTP  bestReg)
{
    RegSet::RegisterPreference pref(needReg, bestReg);
    genCodeForTreeFloat(tree, &pref);
}
static int32_t AddCustomHeader(const char* pHeader)
{
  nsresult rv;
  int32_t index = -1;
  nsCOMPtr<nsIPrefBranch> pref(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
  NS_ENSURE_SUCCESS(rv, index);

  nsAutoCString headers;
  pref->GetCharPref(MAILNEWS_CUSTOM_HEADERS, getter_Copies(headers));
  index = 0;
  if (!headers.IsEmpty())
  {
    char *headersString = ToNewCString(headers);
    nsAutoCString hdrStr;
    hdrStr.Adopt(headersString);
    hdrStr.StripWhitespace();  //remove whitespace before parsing

    char *newStr = headersString;
    char *token = NS_strtok(":", &newStr);
    while (token)
    {
      if (!PL_strcasecmp(token, pHeader))
        return index;
      token = NS_strtok(":", &newStr);
      index++;
    }
    headers += ":";
  }
  headers += pHeader;
  pref->SetCharPref(MAILNEWS_CUSTOM_HEADERS, headers.get());

  return index;
}
nsSize
nsBoxLayout::GetPrefSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState)
{
  nsSize pref (0, 0);
  AddBorderAndPadding(aBox, pref);

  return pref;
}
vector<int> BoyerMoore(const string& str, istream& in) {
	//----------stopTable--
	int stopTable[256];
	for(int i = 0; i < 256; ++i)
		stopTable[i] = 0;

	for(int i = 0; i < str.length(); ++i)
		stopTable[unsigned char(str[i])] = i;
	//-------------------
	vector<int> suffTable(str.length() + 1);
	PrefixFunc pref(str);

	string strReverse(str.length(), 'a');
	for(int i = 0; i < str.length(); ++i)
		strReverse[i] = str[str.length() - i - 1];
	PrefixFunc prefReverse(strReverse);

	for(int i = 0; i < str.length() + 1; ++i)
		suffTable[i] = str.length() - pref[str.length() - 1];

	for(int i = 1; i < str.length(); ++i) {
		int j = prefReverse[i];
		if(j != 0)
			suffTable[j] = min(suffTable[j],  i - j + 1);
	}
	//-----------
	int posEnd = str.length() - 1;
	int posCompare = 0;
	string text = "";
	char c;
	while(in >> c)
		text = text + c;
	//------------
	vector<int> result;
	while(posEnd < text.length()) {
		bool flag = true;
		while(posCompare < str.length()) {
			if(str[str.length() - 1 - posCompare] != text[posEnd - posCompare]) {
				flag = false;
				break;
			}
			++posCompare;
		}

		if(flag) {
			result.push_back(posEnd - str.length() + 1);
			++posEnd;
			posCompare = 0;
		} else {
			if(posCompare > 0)
				posEnd += shift(text[posEnd - posCompare], str[0], str.length() - posCompare - 1, 
				                stopTable[unsigned char(text[posEnd - posCompare])], suffTable[posCompare - 1]);
			else
				posEnd += shift(text[posEnd - posCompare], str[0], str.length() - posCompare - 1, 
				                stopTable[unsigned char(text[posEnd - posCompare])], 1);
			posCompare = 0;
		}
	}
Exemple #16
0
int
launcher_rvgl::_launch(const std::string &host_id) {
    if (_running) return err_already_running;

    std::string dir = pref()->get<std::string>("advanced/rvgl_path", "");
    std::string params = pref()->get<std::string>("advanced/rvgl_cmdline", "");

    if (dir.empty()) {
        win_registry r(win_registry::id_dplay, "", "Re-Volt");
        dir = r.get<std::string>("Path", "");
        pref()->set("advanced/rvgl_path", dir.c_str());
    }

    std::string cmd(dir);
#ifdef WIN32
    cmd += "/rvgl.exe";
#else
    cmd += "/rvgl";
#endif
    cmd = "\"" + cmd + "\"";
    if (!params.empty()) cmd += " " + params;
    cmd += (host_id.empty() ? " -lobby" : " -lobby " + host_id);

    //printf("%s\n", cmd.c_str());
    ACE_DEBUG((LM_DEBUG, "launcher_rvgl: command line: %s\n",
              cmd.c_str()));

    // Launch options
    ACE_Process_Manager *pm = ACE_Process_Manager::instance();
    ACE_Process_Options opts;
    opts.working_directory(dir.c_str());
    opts.command_line(cmd.c_str());
    _rvgl_pid = pm->spawn(opts, this);
    ACE_DEBUG((LM_INFO, "launcher_rvgl: pid %d from thread %t, cmd: %s\n",
               _rvgl_pid, cmd.c_str()));
    if (_rvgl_pid == ACE_INVALID_PID) {
        ACE_ERROR((LM_ERROR, "launcher_rvgl: failed to launch: %s\n",
                  cmd.c_str()));
        return err_could_not_launch;
    }
    
    _running = true;
    
    return 0;
}
 Model::Hit VertexHandleManager::pickHandle(const Ray3& ray, const Renderer::Camera& camera, const Vec3& position, Model::Hit::HitType type) const {
     const FloatType distance = camera.pickPointHandle(ray, position, pref(Preferences::HandleRadius));
     if (!Math::isnan(distance)) {
         const Vec3 hitPoint = ray.pointAtDistance(distance);
         return Model::Hit::hit<Vec3>(type, distance, hitPoint, position);
     }
     
     return Model::Hit::NoHit;
 }
void Highlighter::saveFontSettings(const QFont& font)
{
    QSettings pref( "Castano Inc", "QShaderEdit" );

    pref.beginGroup("CodeEditor");
    pref.setValue("font",font.family());
    pref.setValue("size",font.pointSize());
    pref.endGroup();
}
/*!
    \reimp
*/
void QWidgetItem::setGeometry(const QRect &rect)
{
    if (isEmpty())
        return;

    QRect r = !wid->testAttribute(Qt::WA_LayoutUsesWidgetRect)
            ? fromLayoutItemRect(wid->d_func(), rect)
            : rect;
    const QSize widgetRectSurplus = r.size() - rect.size(); 

    /* 
       For historical reasons, this code is done using widget rect 
       coordinates, not layout item rect coordinates. However, 
       QWidgetItem's sizeHint(), maximumSize(), and heightForWidth() 
       all work in terms of layout item rect coordinates, so we have to 
       add or subtract widgetRectSurplus here and there. The code could 
       be much simpler if we did everything using layout item rect 
       coordinates and did the conversion right before the call to 
       QWidget::setGeometry(). 
     */ 

    QSize s = r.size().boundedTo(maximumSize() + widgetRectSurplus);  
    int x = r.x();
    int y = r.y();
    if (align & (Qt::AlignHorizontal_Mask | Qt::AlignVertical_Mask)) {
        QSize pref(sizeHint());
        QSizePolicy sp = wid->sizePolicy();
        if (sp.horizontalPolicy() == QSizePolicy::Ignored)
            pref.setWidth(wid->sizeHint().expandedTo(wid->minimumSize()).width());
        if (sp.verticalPolicy() == QSizePolicy::Ignored)
            pref.setHeight(wid->sizeHint().expandedTo(wid->minimumSize()).height());
        pref += widgetRectSurplus;
        if (align & Qt::AlignHorizontal_Mask)
            s.setWidth(qMin(s.width(), pref.width()));
        if (align & Qt::AlignVertical_Mask) {
            if (hasHeightForWidth())
                s.setHeight(qMin(s.height(), 
                                 heightForWidth(s.width() - widgetRectSurplus.width()) 
                                 + widgetRectSurplus.height()));
            else
                s.setHeight(qMin(s.height(), pref.height()));
        }
    }
    Qt::Alignment alignHoriz = QStyle::visualAlignment(wid->layoutDirection(), align);
    if (alignHoriz & Qt::AlignRight)
        x = x + (r.width() - s.width());
    else if (!(alignHoriz & Qt::AlignLeft))
        x = x + (r.width() - s.width()) / 2;

    if (align & Qt::AlignBottom)
        y = y + (r.height() - s.height());
    else if (!(align & Qt::AlignTop))
        y = y + (r.height() - s.height()) / 2;

    wid->setGeometry(x, y, s.width(), s.height());
}
 void VertexHandleManager::render(Renderer::RenderContext& renderContext, Renderer::RenderBatch& renderBatch, const bool splitMode) {
     if (!m_renderStateValid)
         validateRenderState(splitMode);
     
     Renderer::RenderService renderService(renderContext, renderBatch);
     renderService.setForegroundColor(pref(Preferences::HandleColor));
     if (m_selectedEdgeHandles.empty() && m_selectedFaceHandles.empty() && !splitMode)
         renderService.renderPointHandles(VectorUtils::cast<Vec3f>(m_unselectedVertexHandlePositions));
     
     if (m_selectedVertexHandles.empty() && m_selectedFaceHandles.empty() && !splitMode)
         renderService.renderPointHandles(VectorUtils::cast<Vec3f>(m_unselectedEdgeHandlePositions));
     
     if (m_selectedVertexHandles.empty() && m_selectedEdgeHandles.empty() && !splitMode)
         renderService.renderPointHandles(VectorUtils::cast<Vec3f>(m_unselectedFaceHandlePositions));
     
     if ((!m_selectedEdgeHandles.empty() || !m_selectedFaceHandles.empty()) && !splitMode)
         renderService.renderLines(m_edgeVertices);
     
     renderService.setForegroundColor(pref(Preferences::SelectedHandleColor));
     renderService.renderPointHandles(VectorUtils::cast<Vec3f>(m_selectedHandlePositions));
 }
 void VertexHandleManager::renderEdgeHighlight(Renderer::RenderContext& renderContext, Renderer::RenderBatch& renderBatch, const Vec3& handlePosition) {
     Renderer::RenderService renderService(renderContext, renderBatch);
     renderService.setForegroundColor(pref(Preferences::HandleColor));
     
     Model::VertexToEdgesMap::const_iterator it = m_unselectedEdgeHandles.find(handlePosition);
     if (it != m_unselectedEdgeHandles.end()) {
         const Model::BrushEdgeSet& edges = it->second;
         assert(!edges.empty());
         
         const Model::BrushEdge* edge = *edges.begin();
         renderService.renderLine(edge->firstVertex()->position(), edge->secondVertex()->position());
     }
 }
        void CreateComplexBrushToolController3D::doRender(const InputState& inputState, Renderer::RenderContext& renderContext, Renderer::RenderBatch& renderBatch) {
            m_tool->render(renderContext, renderBatch);
            
            const Polyhedron3& polyhedron = m_tool->polyhedron();
            if (!polyhedron.empty()) {
                Renderer::RenderService renderService(renderContext, renderBatch);
                renderService.setForegroundColor(pref(Preferences::HandleColor));
                renderService.setLineWidth(2.0f);
                
                const Polyhedron3::EdgeList& edges = polyhedron.edges();
                Polyhedron3::EdgeList::const_iterator eIt, eEnd;
                for (eIt = edges.begin(), eEnd = edges.end(); eIt != eEnd; ++eIt) {
                    const Polyhedron3::Edge* edge = *eIt;
                    renderService.renderLine(edge->firstVertex()->position(), edge->secondVertex()->position());
                }
                
                const Polyhedron3::VertexList& vertices = polyhedron.vertices();
                Polyhedron3::VertexList::const_iterator vIt, vEnd;
                for (vIt = vertices.begin(), vEnd = vertices.end(); vIt != vEnd; ++vIt) {
                    const Polyhedron3::Vertex* vertex = *vIt;
                    renderService.renderPointHandle(vertex->position());
                }
                
                if (polyhedron.polygon() && inputState.modifierKeysDown(ModifierKeys::MKShift)) {
                    const Polyhedron3::Face* face = polyhedron.faces().front();
                    const Vec3::List pos3 = face->vertexPositions();
                    Vec3f::List pos3f(pos3.size());
                    for (size_t i = 0; i < pos3.size(); ++i)
                        pos3f[i] = Vec3f(pos3[i]);
                    
                    renderService.setForegroundColor(Color(pref(Preferences::HandleColor), 0.5f));
                    renderService.renderFilledPolygon(pos3f);

                    std::reverse(pos3f.begin(), pos3f.end());
                    renderService.renderFilledPolygon(pos3f);
                }
            }
        }
Exemple #23
0
// Utility to set PRBool registry value from getter method.
nsresult putPRBoolIntoRegistry( const char* valueName,
                                nsIWindowsHooksSettings *prefs,
                                nsWindowsHooksSettings::getter memFun ) {
    // Use getter method to extract attribute from prefs.
    PRBool boolValue;
    (void)(prefs->*memFun)( &boolValue );
    // Convert to DWORD.
    DWORD  dwordValue = boolValue;
    // Store into registry.
    BoolRegistryEntry pref( valueName );
    nsresult rv = boolValue ? pref.set() : pref.reset();

    return rv;
}
Exemple #24
0
int putstring(int code, int *pKwK) {

    Trie t = C_to_T(code); // DIEs if code invalid
    sawT(t);
    int K = getK(code);

    if (pref(code) == EMPTY) {

        putchar(K); 
        return K;
    }
    else {

        int finalK = putstring(pref(code), NULL);
        if (K != STANDBY) 
            putchar(K);

        else   // KwK; will put second K later
            *pKwK = 1; 

        return finalK;
    }
}
 void CameraTool2D::doMouseScroll(const InputState& inputState) {
     if (zoom(inputState)) {
         const float speed = pref(Preferences::CameraMouseWheelInvert) ? -1.0f : 1.0f;
         if (inputState.scrollY() != 0.0f) {
             const Vec2f mousePos(static_cast<float>(inputState.mouseX()), static_cast<float>(inputState.mouseY()));
             const Vec3f oldWorldPos = m_camera.unproject(mousePos.x(), mousePos.y(), 0.0f);
             
             const float factor = 1.0f + inputState.scrollY() / 50.0f * speed;
             m_camera.zoom(factor);
             
             const Vec3f newWorldPos = m_camera.unproject(mousePos.x(), mousePos.y(), 0.0f);
             const Vec3f delta = newWorldPos - oldWorldPos;
             m_camera.moveBy(-delta);
         }
     }
 }
NS_IMETHODIMP
nsXPInstallManager::ConfirmInstall(nsIDOMWindow *aParent, const PRUnichar **aPackageList, PRUint32 aCount, PRBool *aRetval)
{
    *aRetval = PR_FALSE;

    nsCOMPtr<nsIDOMWindowInternal> parentWindow( do_QueryInterface(aParent) );
    nsCOMPtr<nsIDialogParamBlock> params;
    nsresult rv = LoadParams( aCount, aPackageList, getter_AddRefs(params) );

    if ( NS_SUCCEEDED(rv) && parentWindow && params)
    {
        nsCOMPtr<nsIDOMWindow> newWindow;

        nsCOMPtr<nsISupportsInterfacePointer> ifptr =
            do_CreateInstance(NS_SUPPORTS_INTERFACE_POINTER_CONTRACTID, &rv);
        NS_ENSURE_SUCCESS(rv, rv);

        ifptr->SetData(params);
        ifptr->SetDataIID(&NS_GET_IID(nsIDialogParamBlock));

        char* confirmDialogURL;
        nsCOMPtr<nsIPrefBranch> pref(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
        if (!pref)
          return rv;

        rv = pref->GetCharPref(PREF_XPINSTALL_CONFIRM_DLG, &confirmDialogURL);
        NS_ASSERTION(NS_SUCCEEDED(rv), "Can't invoke XPInstall FE without a FE URL! Set xpinstall.dialog.confirm");
        if (NS_FAILED(rv))
          return rv;

        rv = parentWindow->OpenDialog(NS_ConvertASCIItoUTF16(confirmDialogURL),
                                      NS_LITERAL_STRING("_blank"),
                                      NS_LITERAL_STRING("chrome,centerscreen,modal,titlebar"),
                                      ifptr,
                                      getter_AddRefs(newWindow));

        if (NS_SUCCEEDED(rv))
        {
            //Now get which button was pressed from the ParamBlock
            PRInt32 buttonPressed = 0;
            params->GetInt( 0, &buttonPressed );
            *aRetval = buttonPressed ? PR_FALSE : PR_TRUE;
        }
    }

    return rv;
}
void Highlighter::writeSettings(FormatType f, const QTextCharFormat& format)
{
    QSettings pref( "Castano Inc", "QShaderEdit" );

    pref.beginGroup("CodeEditor");

    QString color = format.foreground().color().name();
    int type=0; //0 - normal,1 - bold,2 - italic 3 - bold&itelic

    if(format.fontWeight() == QFont::Normal)
        type = 0;
    else if(format.fontWeight() == QFont::Bold)
        type = 1;

    if((format.fontItalic()) && (format.fontWeight() == QFont::Bold))
        type = 3;
    else if(format.fontItalic())
        type = 2;

    switch(f)
        {
            case Keyword : pref.beginGroup("Keyword");
                           break;
            case Comment : pref.beginGroup("Comment");
                           break;
            case DataType :pref.beginGroup("DataType");
                           break;
            case BuiltinVar : pref.beginGroup("BuiltinVar");
                           break;
            case BuiltinFunction : pref.beginGroup("BuiltinFunction");
                           break;
            case Number : pref.beginGroup("Number");
                           break;
            case String : pref.beginGroup("String");
                           break;
            case Misc : pref.beginGroup("Misc");
                           break;
            case FormatType_Max: break; //for compiler :)
            default: return;
        }

   pref.setValue("color",color);
   pref.setValue("type",type);
   pref.endGroup();
   pref.endGroup();
}
NS_IMETHODIMP nsMsgContentPolicy::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *aData)
{
    if (!strcmp(NS_PREFBRANCH_PREFCHANGE_TOPIC_ID, aTopic))
    {
        NS_LossyConvertUTF16toASCII pref(aData);

        nsresult rv;

        nsCOMPtr<nsIPrefBranch2> prefBranchInt = do_QueryInterface(aSubject, &rv);
        NS_ENSURE_SUCCESS(rv, rv);

        if (pref.Equals(kBlockRemoteImages))
            prefBranchInt->GetBoolPref(kBlockRemoteImages, &mBlockRemoteImages);
    }

    return NS_OK;
}
Exemple #29
0
kernel::ModelObjectsTemp RigidBodyUmbrella::do_get_inputs() const {
    kernel::Model *m = get_model();
    ModelObjectsTemp ret;
    //reference rb
    ret.push_back(m->get_particle(ref_));
    kernel::ParticleIndexes pref(
        RigidBody(m, ref_).get_member_indexes());
    for (unsigned i=0; i<pref.size(); i++)
        ret.push_back(m->get_particle(pref[i]));
    //target rb
    ret.push_back(m->get_particle(pi_));
    kernel::ParticleIndexes iref(
        RigidBody(m, pi_).get_member_indexes());
    for (unsigned i=0; i<iref.size(); i++)
        ret.push_back(m->get_particle(iref[i]));
    return ret;
}
Exemple #30
0
nsSize
nsBox::GetPrefSize(nsBoxLayoutState& aState)
{
  NS_ASSERTION(aState.GetRenderingContext(), "must have rendering context");

  nsSize pref(0,0);
  DISPLAY_PREF_SIZE(this, pref);

  if (IsCollapsed(aState))
    return pref;

  AddBorderAndPadding(pref);
  nsIBox::AddCSSPrefSize(aState, this, pref);

  nsSize minSize = GetMinSize(aState);
  nsSize maxSize = GetMaxSize(aState);
  return BoundsCheck(minSize, pref, maxSize);
}