Beispiel #1
0
ToolButton::ToolButton( QAction * _a, const QString & _label,
				const QString & _alt_label,
				const QString & _desc, QObject * _receiver, 
				const char * _slot, QWidget * _parent ) :
	QToolButton( _parent ),
	m_pixmap( _a->icon().pixmap( 128, 128 ) ),
	m_img( FastQImage( m_pixmap.toImage() ).scaled( 32, 32 ) ),
	m_mouseOver( false ),
	m_label( _label ),
	m_altLabel( _alt_label ),
	m_title( _a->text() ),
	m_descr( _desc )
{
	setAttribute( Qt::WA_NoSystemBackground, true );

	updateSize();

	if( _receiver != NULL && _slot != NULL )
	{
		connect( this, SIGNAL( clicked() ), _receiver, _slot );
		connect( _a, SIGNAL( triggered( bool ) ), _receiver, _slot );
	}

}
void HashTable<Type>:: add(HashNode<Type> currentNode)
{
    if(!contains(currentNode))
    {
        if(this->size/this->capacity >= this->efficiencyPercentile)
        {
            updateSize();
        }
        int positionToInsert = findPosition(currentNode);
        
        if(internalStorage[positionToInsert] != nullptr)
        {
            while(internalStorage[positionToInsert] != nullptr)
            {
                positionToInsert = (positionToInsert +1) % size;
            }
            internalStorage[positionToInsert] = &currentNode;
        }
        else
        {
            internalStorage[positionToInsert] = &currentNode;
        }
    }
}
TEST_F(CpuMultiplicativeInteractionModelTest, Construct) {
  const int numberOfIndividuals = 10;
  MKLWrapper& mklWrapper;
  CpuMultiplicativeInteractionModel cpuMultiplicativeInteractionModel(mklWrapper);

  Container::RegularHostVector snpData(numberOfIndividuals);
  Container::RegularHostVector envData(numberOfIndividuals);
  Container::RegularHostVector interData(numberOfIndividuals);

  for(int i = 0; i < numberOfIndividuals; ++i){
    snpData(i) = i;
  }

  for(int i = 0; i < numberOfIndividuals; ++i){
    envData(i) = numberOfIndividuals - i;
  }

  Container::SNPVectorMock<Container::RegularHostVector> snpVectorMock;
  EXPECT_CALL(snpVectorMock, getNumberOfIndividualsToInclude()).WillRepeatedly(Return(numberOfIndividuals));
  EXPECT_CALL(snpVectorMock, getOriginalSNPData()).Times(1).WillRepeatedly(ReturnRef(snpData));

  Container::EnvironmentVectorMock<Container::RegularHostVector> environmentVectorMock;
  EXPECT_CALL(environmentVectorMock, getNumberOfIndividualsToInclude()).WillRepeatedly(Return(numberOfIndividuals));
  EXPECT_CALL(environmentVectorMock, getEnvironmentData()).Times(1).WillRepeatedly(ReturnRef(envData));

  Container::InteractionVectorMock<Container::RegularHostVector> interactionVectorMock;
  EXPECT_CALL(interactionVectorMock, getNumberOfIndividualsToInclude()).WillRepeatedly(Return(numberOfIndividuals));
  EXPECT_CALL(interactionVectorMock, getInteractionData()).Times(1).WillRepeatedly(ReturnRef(interData));
  EXPECT_CALL(interactionVectorMock, updateSize(numberOfIndividuals)).Times(1);

  cpuMultiplicativeInteractionModel.applyModel(snpVectorMock, environmentVectorMock, interactionVectorMock);

  for(int i = 0; i < numberOfIndividuals; ++i){
    EXPECT_EQ(i * (numberOfIndividuals - i), interData(i));
  }
}
Beispiel #4
0
	MessageBoxStyle Message::addButtonName(const UString& _name)
	{
		//FIXME
		if (mVectorButton.size() >= MessageBoxStyle::_CountUserButtons)
		{
			MYGUI_LOG(Warning, "Too many buttons in message box, ignored");
			return MessageBoxStyle::None;
		}
		// бит, номер кнопки + смещение до Button1
		MessageBoxStyle info = MessageBoxStyle(MessageBoxStyle::Enum(MYGUI_FLAG(mVectorButton.size() + MessageBoxStyle::_IndexUserButton1)));

		// запоминаем кнопки для отмены и подтверждения
		if (mVectorButton.empty()) mInfoOk = info;
		mInfoCancel = info;

		Widget* button = createWidgetT(mButtonType, mButtonSkin, IntCoord(), Align::Left | Align::Bottom);
		button->eventMouseButtonClick = newDelegate(this, &Message::notifyButtonClick);
		button->setCaption(_name);
		button->_setInternalData(info);
		mVectorButton.push_back(button);

		updateSize();
		return info;
	}
Beispiel #5
0
void GlfwGraphics::createWindow(const char* title, int width, int height)
{
	// Open a window and create its OpenGL context
	if( !glfwOpenWindow( width, height, 0, 0, 0, 0, 0, 0, GLFW_WINDOW ) )
	{
		::glfwTerminate();
		throw GdxRuntimeException("Failed to open GLFW window");
	}
	::glfwSetWindowTitle(title);
	
	//initializa glew
	glewInit();

	updateSize();

	//TODO: implement also window resize
	//setup a callback?

	m_listener.create();

	m_frameStart = m_timer.systemNanoSeconds();
	m_lastFrameTime = m_frameStart;
	m_deltaTime = 0;
}
void PGE_QuestionBox::construct(QString _title, PGE_MenuBox::msgType _type,
                            PGE_Point pos, float _padding, QString texture)
{
    if(!texture.isEmpty())
        loadTexture(texture);

    updateTickValue();
    _page=0;
    running=false;
    _answer_id = -1;
    _pos=pos;
    _menu.setTextLenLimit(30, true);
    _menu.setItemsNumber(2);
    setTitleFont(ConfigManager::setup_menu_box.title_font_name);
    setTitleFontColor(ConfigManager::setup_menu_box.title_font_rgba);
    /****************Word wrap*********************/
    title = _title;
    FontManager::optimizeText(title, 27);
    title_size = FontManager::textSize(_title, fontID, 27);
    /****************Word wrap*end*****************/
    setPadding(_padding);
    setType(_type);
    updateSize();
}
Beispiel #7
0
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
{
    QWidget *centralWidget=new QWidget;

    QLabel *fontLabel=new QLabel(tr("Font:"));
    fontCombo =new QFontComboBox;
    QLabel *sizeLabel =new QLabel(tr("Size:"));
    sizeCombo =new QComboBox;
    QLabel *styleLabel=new QLabel(tr("Style:"));
    styleCombo =new QComboBox;
    QLabel *fontMeringLabel=new Qlabel(tr("Automatic Font Mergint:"));
    fontMerging=new QCheckBox;
    fontMerging->setChecked(true);

    scrollArea =new QScrollArea;
    characterWidget =new characterWidget;
    scrollArea->setWidget(characterWidget);

    findStyles(fontCombo->currentData());

    lineEdit=new QLineEdit;
#ifndef QT_NO_CLIPBOARD
    QPushButton *clipboardButton =new QpushButton(tr("&To clipboard"));

    connect(fontCombo, SIGNAL(currentFontChanged(QFont)),
            this, SLOT(findStyles(QFont)));
    connect(fontCombo, SIGNAL(currentFontChanged(QFont)),
            this, SLOT(findSizes(QFont)));
    connect(fontCombo, SIGNAL(currentFontChanged(QFont)),
            characterWidget, SLOT(updateFont(QFont)));
    connect(sizeCombo, SIGNAL(currentIndexChanged(QString)),
            characterWidget, SLOT(updateSize(QString)));
    connect(styleCombo, SIGNAL(currentIndexChanged(QString)),
            characterWidget, SLOT(updateStyle(QString)));

}
void BokehBlurOperation::executeOpenCL(OpenCLDevice *device,
                                       MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, 
                                       MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, 
                                       list<cl_kernel> *clKernelsToCleanUp) 
{
	cl_kernel kernel = device->COM_clCreateKernel("bokehBlurKernel", NULL);
	if (!this->m_sizeavailable) {
		updateSize();
	}
	const float max_dim = max(this->getWidth(), this->getHeight());
	cl_int radius = this->m_size * max_dim / 100.0f;
	cl_int step = this->getStep();
	
	device->COM_clAttachMemoryBufferToKernelParameter(kernel, 0, -1, clMemToCleanUp, inputMemoryBuffers, this->m_inputBoundingBoxReader);
	device->COM_clAttachMemoryBufferToKernelParameter(kernel, 1,  4, clMemToCleanUp, inputMemoryBuffers, this->m_inputProgram);
	device->COM_clAttachMemoryBufferToKernelParameter(kernel, 2,  -1, clMemToCleanUp, inputMemoryBuffers, this->m_inputBokehProgram);
	device->COM_clAttachOutputMemoryBufferToKernelParameter(kernel, 3, clOutputBuffer);
	device->COM_clAttachMemoryBufferOffsetToKernelParameter(kernel, 5, outputMemoryBuffer);
	clSetKernelArg(kernel, 6, sizeof(cl_int), &radius);
	clSetKernelArg(kernel, 7, sizeof(cl_int), &step);
	device->COM_clAttachSizeToKernelParameter(kernel, 8, this);
	
	device->COM_clEnqueueRange(kernel, outputMemoryBuffer, 9, this);
}
Beispiel #9
0
IntSize BitmapImage::size() const
{
    updateSize();
    return m_size;
}
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
void OriginSymbol::setPreferredMagnitudeValue(double magnitudeValue) {
	_magnitude = magnitudeValue;
	updateSize();
}
void CDesertConfigDialog::OnLvnItemchangedCfglist(NMHDR *pNMHDR, LRESULT *pResult)
{
	LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
	// TODO: Add your control notification handler code here	
	if( pNMLV->uNewState & LVIS_SELECTED )
	{
		int sel = pNMLV->iItem;
		for(map<HTREEITEM, int>::iterator it=cfgTreeMap.begin();it!=cfgTreeMap.end();++it)
		{
			HTREEITEM node = (*it).first;			
			int elemId = (*it).second;
			if(elemId==0)
			{
				HTREEITEM parent_node = m_cfgtree.GetParentItem(node);
				
				HTREEITEM hNextItem;
				HTREEITEM hChildItem = m_cfgtree.GetChildItem(parent_node);

				bool selected = true;
				bool otherSel = false;
				while (hChildItem != NULL)
				{
					map<HTREEITEM, int>::iterator pos = cfgTreeMap.find(hChildItem);
					if(pos!=cfgTreeMap.end())
					{
						int itemId = (*pos).second;
						if(itemId!=0 && dhelper_ptr->isElementSelected(sel, itemId, true))
						{
							selected = false;
							otherSel = true;
							break;
						}
					}
					hNextItem = m_cfgtree.GetNextItem(hChildItem, TVGN_NEXT);
					hChildItem = hNextItem;
				}	
				if(!otherSel)
				{
					map<HTREEITEM, int>::iterator pos = cfgTreeMap.find(parent_node);
					if(pos!=cfgTreeMap.end())
					{
						int itemId = (*pos).second;
						if(itemId!=0 && dhelper_ptr->isElementSelected(sel, itemId, true))
							selected = true;
						else
							selected = false;
					}
					else
						selected = false;
				}
				  
				if(selected)
					m_cfgtree.SetItemState(node,TVIS_BOLD, TVIS_BOLD); 
				else
					m_cfgtree.SetItemState(node,0, TVIS_BOLD); 
			}
			else
			{
				if(dhelper_ptr->isElementSelected(sel, elemId))
					m_cfgtree.SetItemState(node,TVIS_BOLD, TVIS_BOLD); 
				else
					m_cfgtree.SetItemState(node,0, TVIS_BOLD); 
			}
		}
	}	
		

	int ns = pNMLV->uNewState & LVIS_STATEIMAGEMASK;

	if ((ns & 0x2000) != 0)
		checkedSize++;
	else if ((ns & 0x1000) != 0)
		checkedSize--;

	updateSize();

	*pResult = 0;
}
Beispiel #12
0
void FrameBuffer::resize(const QSize &size) {
	this->size = size;
	updateSize();
}
void StrokeProcessState::updateState(ParamBox input)
{
    this->prevParam = curParam;
    this->curParam = input;
    //Compare the difference between curParam and prevParam, then update according to the changes

    if (this->StrokeList.empty())
    {   NUS_Weibull(this->imgData->SaliencyImage, & (this->StrokeList), this->curParam.mDensity,this->curParam.mNon_Uniformity);

    }

    if (laterUpdate_graph) //re-update the saliency sampling-> initial connection graph
    {
        //NUS_Weibull(this->imgData->SaliencyImage, & (this->StrokeList), this->curParam.mDensity,this->curParam.mNon_Uniformity);
        initStrokeOrientation(StrokeList, this->imgData->GradientOrientation);
        connectStrokeGraph(StrokeList, this->imgData->SegmentImage);
        //Debug use ...Show Image
        //vis_StrokePositions(this->imgData->OriginalImage, this->StrokeList);

    }

    if (curParam.mLocal_Iostropy != prevParam.mLocal_Iostropy || laterUpdate_graph) // update connection graph
    {
        updateOrientation(this->StrokeList, this->curParam.mLocal_Iostropy);
        connectStrokeGraph(StrokeList, this->imgData->SegmentImage);
        laterUpdate_graph = true;
    }
    if (curParam.mCoarseness != prevParam.mCoarseness || laterUpdate_graph)  // reinitialize the size
    {
        initStrokeSize(this->imgData->SaliencyImage, this->imgData->GradientRatio, (this->StrokeList), this->curParam.mCoarseness);
        laterUpdate_size = true;
    }
    if (curParam.mSize_Contrast!=prevParam.mSize_Contrast || laterUpdate_graph || laterUpdate_size) //update size
    {
        updateSize(StrokeList, this->curParam.mSize_Contrast);
    }

    /*if (laterUpdate_graph || laterUpdate_size)
    {
    initStrokeColor(StrokeList, this->imgData->OriginalImage);

    }*/

    if (curParam.mHue_Constrast != prevParam.mHue_Constrast ||
            curParam.mLightness_Contrast != prevParam.mLightness_Contrast||
            curParam.mChroma_Constrast != prevParam.mChroma_Constrast||
            laterUpdate_graph||laterUpdate_size ) //update the three color channels separately
    {
        initStrokeColor(StrokeList, this->imgData->OriginalImage);
        updateHue(StrokeList,curParam.mHue_Constrast);
        updateLightness(StrokeList, curParam.mLightness_Contrast);
        updateChroma(StrokeList, curParam.mChroma_Constrast);


    }

    //if (curParam.mLightness_Contrast != prevParam.mLightness_Contrast ||laterUpdate_graph||laterUpdate_size) //update the three color channels separately
    //{
    //	updateLightness(StrokeList, curParam.mLightness_Contrast);
    //}

    //if (curParam.mChroma_Constrast != prevParam.mChroma_Constrast ||laterUpdate_graph||laterUpdate_size) //update the three color channels separately
    //{
    //	updateChroma(StrokeList, curParam.mChroma_Constrast);
    //}



}
Beispiel #14
0
void SDL2Window::changeMode(DisplayMode mode, bool makeFullscreen) {

    if(!m_window) {
        m_size = mode.resolution;
        m_fullscreen = makeFullscreen;
        return;
    }

    if(m_fullscreen == makeFullscreen && m_size == mode.resolution) {
        return;
    }

    bool wasFullscreen = m_fullscreen;

    m_renderer->beforeResize(false);

    if(makeFullscreen) {
        if(wasFullscreen) {
            // SDL will not update the window size with the new mode if already fullscreen
            SDL_SetWindowFullscreen(m_window, 0);
        }
        if(mode.resolution != Vec2i_ZERO) {
            SDL_DisplayMode sdlmode;
            SDL_DisplayMode requested;
            requested.driverdata = NULL;
            requested.format = 0;
            requested.refresh_rate = 0;
            requested.w = mode.resolution.x;
            requested.h = mode.resolution.y;
            int display = SDL_GetWindowDisplayIndex(m_window);
            if(!SDL_GetClosestDisplayMode(display, &requested, &sdlmode)) {
                if(SDL_GetDesktopDisplayMode(display, &sdlmode)) {
                    return;
                }
            }
            if(SDL_SetWindowDisplayMode(m_window, &sdlmode) < 0) {
                return;
            }
        }
    }

    Uint32 flags = getSDLFlagsForMode(mode.resolution, makeFullscreen);
    if(SDL_SetWindowFullscreen(m_window, flags) < 0) {
        return;
    }

    if(!makeFullscreen) {
        SDL_SetWindowSize(m_window, mode.resolution.x, mode.resolution.y);
    }

    if(wasFullscreen != makeFullscreen) {
        onToggleFullscreen(makeFullscreen);
    }

    if(makeFullscreen) {
        // SDL regrettably sends resize events when a fullscreen window is minimized.
        // Because of that we ignore all size change events when fullscreen.
        // Instead, handle the size change here.
        updateSize();
    }

    tick();
}
Beispiel #15
0
Icon::Icon(TaskManager::AbstractGroupableItem *abstractItem, Launcher *launcher, Job *job, Applet *parent) : QGraphicsWidget(parent),
    m_applet(parent),
    m_task(NULL),
    m_launcher(NULL),
    m_glowEffect(NULL),
    m_layout(new QGraphicsLinearLayout(this)),
    m_animationTimeLine(new QTimeLine(1000, this)),
    m_jobAnimationTimeLine(NULL),
    m_itemType(TypeOther),
    m_factor(parent->initialFactor()),
    m_animationProgress(-1),
    m_jobsProgress(0),
    m_jobsAnimationProgress(0),
    m_dragTimer(0),
    m_highlightTimer(0),
    m_menuVisible(false),
    m_demandsAttention(false),
    m_jobsRunning(false),
    m_isVisible(true),
    m_isPressed(false)
{
    setObjectName("FancyTasksIcon");

    setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));

    setAcceptsHoverEvents(true);

    setAcceptDrops(true);

    setFocusPolicy(Qt::StrongFocus);

    setFlag(QGraphicsItem::ItemIsFocusable);

    setLayout(m_layout);

    m_visualizationPixmap = NULL;

    m_thumbnailPixmap = NULL;

    m_animationTimeLine->setFrameRange(0, 100);
    m_animationTimeLine->setUpdateInterval(50);
    m_animationTimeLine->setCurveShape(QTimeLine::LinearCurve);

    m_layout->setOrientation((m_applet->location() == Plasma::LeftEdge || m_applet->location() == Plasma::RightEdge)?Qt::Vertical:Qt::Horizontal);
    m_layout->addStretch();
    m_layout->addStretch();

    if (abstractItem)
    {
        setTask(abstractItem);
    }
    else if (launcher)
    {
        setLauncher(launcher);
    }
    else if (job)
    {
        addJob(job);
    }

    connect(this, SIGNAL(destroyed()), m_applet, SLOT(updateSize()));
    connect(this, SIGNAL(hoverMoved(QGraphicsWidget*, qreal)), m_applet, SLOT(itemHoverMoved(QGraphicsWidget*, qreal)));
    connect(this, SIGNAL(hoverLeft()), m_applet, SLOT(hoverLeft()));
    connect(m_applet, SIGNAL(sizeChanged(qreal)), this, SLOT(setSize(qreal)));
    connect(m_applet, SIGNAL(sizeChanged(qreal)), this, SIGNAL(sizeChanged(qreal)));
    connect(m_animationTimeLine, SIGNAL(finished()), this, SLOT(stopAnimation()));
    connect(m_animationTimeLine, SIGNAL(frameChanged(int)), this, SLOT(progressAnimation(int)));
}
void QtWaitingSpinner::setRadius(int radius) {
	myRadius = radius;
	updateSize();
}
Beispiel #17
0
bool SDL2Window::initialize() {

    arx_assert(!m_displayModes.empty());

    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
    SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);

#if ARX_PLATFORM == ARX_PLATFORM_WIN32
    // Used on Windows to prevent software opengl fallback.
    // The linux situation:
    // Causes SDL to require visuals without caveats.
    // On linux some drivers only supply multisample capable GLX Visuals
    // with a GLX_NON_CONFORMANT_VISUAL_EXT caveat.
    // see: https://www.opengl.org/registry/specs/EXT/visual_rating.txt
    SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);
#endif

    // TODO EGL and core profile are not supported yet
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY);

    if(gldebug::isEnabled()) {
        SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG);
    }


    int x = SDL_WINDOWPOS_UNDEFINED, y = SDL_WINDOWPOS_UNDEFINED;
    Uint32 windowFlags = getSDLFlagsForMode(m_size, m_fullscreen);
    windowFlags |= SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIDDEN;

    for(int msaa = m_maxMSAALevel; msaa > 0; msaa--) {
        bool lastTry = (msaa == 1);

        // Cleanup context and window from previous tries
        if(m_glcontext) {
            SDL_GL_DeleteContext(m_glcontext);
            m_glcontext = NULL;
        }
        if(m_window) {
            SDL_DestroyWindow(m_window);
            m_window = NULL;
        }

        SDL_ClearError();

        SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, msaa > 1 ? 1 : 0);
        SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, msaa > 1 ? msaa : 0);

        m_window = SDL_CreateWindow(m_title.c_str(), x, y, m_size.x, m_size.y, windowFlags);
        if(!m_window) {
            if(lastTry) {
                LogError << "Could not create window: " << SDL_GetError();
                return false;
            }
            continue;
        }

        m_glcontext = SDL_GL_CreateContext(m_window);
        if(!m_glcontext) {
            if(lastTry) {
                LogError << "Could not create GL context: " << SDL_GetError();
                return false;
            }
            continue;
        }

        // Verify that the MSAA setting matches what was requested
        int msaaEnabled, msaaValue;
        SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &msaaEnabled);
        SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &msaaValue);
        if(!lastTry) {
            if(!msaaEnabled || msaaValue < msaa) {
                continue;
            }
        }
        if(msaaEnabled) {
            m_MSAALevel = msaaValue;
        } else {
            m_MSAALevel = 0;
        }

        // Verify that we actually got an accelerated context
        (void)glGetError(); // clear error flags
        GLint texunits = 0;
        glGetIntegerv(GL_MAX_TEXTURE_UNITS, &texunits);
        if(glGetError() != GL_NO_ERROR || texunits < GLint(m_minTextureUnits)) {
            if(lastTry) {
                LogError << "Not enough GL texture units available: have " << texunits
                         << ", need at least " << m_minTextureUnits;
                return false;
            }
            continue;
        }

        // All good
        const char * system = "(unknown)";
        {
            ARX_SDL_SysWMinfo info;
            info.version.major = 2;
            info.version.minor = 0;
            info.version.patch = 4;
            if(SDL_GetWindowWMInfo(m_window, reinterpret_cast<SDL_SysWMinfo *>(&info))) {
                switch(info.subsystem) {
                case ARX_SDL_SYSWM_UNKNOWN:
                    break;
                case ARX_SDL_SYSWM_WINDOWS:
                    system = "Windows";
                    break;
                case ARX_SDL_SYSWM_X11:
                    system = "X11";
                    break;
#if SDL_VERSION_ATLEAST(2, 0, 3)
                case ARX_SDL_SYSWM_WINRT:
                    system = "WinRT";
                    break;
#endif
                case ARX_SDL_SYSWM_DIRECTFB:
                    system = "DirectFB";
                    break;
                case ARX_SDL_SYSWM_COCOA:
                    system = "Cocoa";
                    break;
                case ARX_SDL_SYSWM_UIKIT:
                    system = "UIKit";
                    break;
#if SDL_VERSION_ATLEAST(2, 0, 2)
                case ARX_SDL_SYSWM_WAYLAND:
                    system = "Wayland";
                    break;
                case ARX_SDL_SYSWM_MIR:
                    system = "Mir";
                    break;
#endif
#if SDL_VERSION_ATLEAST(2, 0, 4)
                case ARX_SDL_SYSWM_ANDROID:
                    system = "Android";
                    break;
#endif
                }
            }
        }

        int red = 0, green = 0, blue = 0, alpha = 0, depth = 0, doublebuffer = 0;
        SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &red);
        SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &green);
        SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &blue);
        SDL_GL_GetAttribute(SDL_GL_ALPHA_SIZE, &alpha);
        SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &depth);
        SDL_GL_GetAttribute(SDL_GL_DOUBLEBUFFER, &doublebuffer);
        LogInfo << "Window: " << system << " r:" << red << " g:" << green << " b:" << blue
                << " a:" << alpha << " depth:" << depth << " aa:" << msaa << "x"
                << " doublebuffer:" << doublebuffer;
        break;
    }

    // Use the executable icon for the window
#if ARX_PLATFORM == ARX_PLATFORM_WIN32
    {
        SDL_SysWMinfo info;
        SDL_VERSION(&info.version);
        if(SDL_GetWindowWMInfo(m_window, &info) && info.subsystem == SDL_SYSWM_WINDOWS) {
            platform::WideString filename;
            filename.allocate(filename.capacity());
            while(true) {
                DWORD size = GetModuleFileNameW(NULL, filename.data(), filename.size());
                if(size < filename.size()) {
                    filename.resize(size);
                    break;
                }
                filename.allocate(filename.size() * 2);
            }
            HICON largeIcon = 0;
            HICON smallIcon = 0;
            ExtractIconExW(filename, 0, &largeIcon, &smallIcon, 1);
            if(smallIcon) {
                SendMessage(info.info.win.window, WM_SETICON, ICON_SMALL, LPARAM(smallIcon));
            }
            if(largeIcon) {
                SendMessage(info.info.win.window, WM_SETICON, ICON_BIG, LPARAM(largeIcon));
            }
        }
    }
#endif

    setVSync(m_vsync);

    SDL_ShowWindow(m_window);
    SDL_ShowCursor(SDL_DISABLE);

    m_renderer->initialize();

    onCreate();
    onToggleFullscreen(m_fullscreen);
    updateSize(true);

    onShow(true);
    onFocus(true);

    return true;
}
void StatusBarWidget::resizeEvent(QResizeEvent *event)
{
	QStatusBar::resizeEvent(event);

	updateSize();
}
Beispiel #19
0
void SDL2Window::tick() {

    SDL_Event event;
    while(SDL_PollEvent(&event)) {

        switch(event.type) {

        case SDL_WINDOWEVENT: {
            switch(event.window.event) {

            case SDL_WINDOWEVENT_SHOWN:
                onShow(true);
                break;
            case SDL_WINDOWEVENT_HIDDEN:
                onShow(false);
                break;
            case SDL_WINDOWEVENT_EXPOSED:
                onPaint();
                break;
            case SDL_WINDOWEVENT_MINIMIZED:
                onMinimize();
                break;
            case SDL_WINDOWEVENT_MAXIMIZED:
                onMaximize();
                break;
            case SDL_WINDOWEVENT_RESTORED:
                onRestore();
                break;
            case SDL_WINDOWEVENT_FOCUS_GAINED:
                onFocus(true);
                break;
            case SDL_WINDOWEVENT_FOCUS_LOST:
                onFocus(false);
                break;

            case SDL_WINDOWEVENT_MOVED: {
                onMove(event.window.data1, event.window.data2);
                break;
            }

            case SDL_WINDOWEVENT_SIZE_CHANGED: {
                Vec2i newSize(event.window.data1, event.window.data2);
                if(newSize != m_size && !m_fullscreen) {
                    m_renderer->beforeResize(false);
                    updateSize();
                } else {
                    // SDL regrettably sends resize events when a fullscreen window
                    // is minimized - we'll have none of that!
                }
                break;
            }

            case SDL_WINDOWEVENT_CLOSE: {
                // The user has requested to close a single window
                // TODO we only support one main window for now
                break;
            }

            }
            break;
        }

        case SDL_QUIT: {
            // The user has requested to close the whole program
            // TODO onDestroy() fits SDL_WINDOWEVENT_CLOSE better, but SDL captures Ctrl+C
            // evenst and *only* sends the SDL_QUIT event for them while normal close
            // generates *both* SDL_WINDOWEVENT_CLOSE and SDL_QUIT
            onDestroy();
            return; // abort event loop!
        }

        }

        if(m_input) {
            m_input->onEvent(event);
        }

    }

    if(!m_renderer->isInitialized()) {
        updateSize();
        m_renderer->afterResize();
        m_renderer->SetViewport(Rect(m_size.x, m_size.y));
    }
}
Beispiel #20
0
////////////////////////////////////////////////////////////////////////////////
// Get width
////////////////////////////////////////////////////////////////////////////////
float RichText::getWidth() const
{
  updateSize();
  return mySize.x;
}
Beispiel #21
0
void FrameBuffer::rescale(int scale) {
	this->_scale = scale;
	updateSize();
}
Beispiel #22
0
////////////////////////////////////////////////////////////////////////////////
// Get height
////////////////////////////////////////////////////////////////////////////////
float RichText::getHeight() const
{
  updateSize();
  return mySize.y;
}
Beispiel #23
0
void KWCanvasItem::pageSetupChanged()
{
    m_viewMode->pageSetupChanged();
    updateSize();
}
void ElementaryStreamDescriptorBox::writeBox(BitStream& bitstr) const
{
    writeFullBoxHeader(bitstr);

    bitstr.write8Bits(mES_Descriptor.ES_DescrTag);

    bool esSizeConverged = false;
    std::uint64_t esSizeSize;
    std::uint32_t esDescriptorSize = mES_Descriptor.size;

    BitStream esBitstr;
    /* Write the whole stuff, then figure out if we wrote the correct
     * size for it (we allos mES_Descriptor to be incorrect); rewrite
     * everything with the correct size. However, this may increase
     * the size due to bigger size having been written and thus moving
     * the remaining of the data forward, so we may need to loop even
     * thrice. */
    while (!esSizeConverged)
    {
        esBitstr.clear();
        esSizeSize = writeSize(esBitstr, esDescriptorSize);
        esBitstr.write16Bits(mES_Descriptor.ES_ID);
        esBitstr.write8Bits(mES_Descriptor.flags);
        if (mES_Descriptor.flags & 0x80)  // streamDependenceFlag as defined in 7.2.6.5.1 of ISO/IEC 14486-1:2010(E)
        {
            esBitstr.write16Bits(mES_Descriptor.dependsOn_ES_ID);
        }

        if (mES_Descriptor.flags & 0x40)  // URL_Flag as defined in 7.2.6.5.1 of ISO/IEC 14486-1:2010(E)
        {
            esBitstr.write8Bits(mES_Descriptor.URLlength);
            if (mES_Descriptor.URLlength)
            {
                esBitstr.writeString(mES_Descriptor.URLstring);
            }
        }

        if (mES_Descriptor.flags & 0x20)  // OCRstreamFlag as defined in 7.2.6.5.1 of ISO/IEC 14486-1:2010(E)
        {
            esBitstr.write16Bits(mES_Descriptor.OCR_ES_Id);
        }

        esBitstr.write8Bits(mES_Descriptor.decConfigDescr.DecoderConfigDescrTag);

        BitStream decConfigBitstr;
        std::uint64_t decConfigSize = mES_Descriptor.decConfigDescr.size;
        std::uint64_t decConfigSizeSize;
        bool decConfigSizeConverged = false;
        while (!decConfigSizeConverged)
        {
            decConfigBitstr.clear();
            decConfigSizeSize = writeSize(decConfigBitstr, static_cast<uint32_t>(decConfigSize));
            decConfigBitstr.write8Bits(mES_Descriptor.decConfigDescr.objectTypeIndication);
            decConfigBitstr.write8Bits((mES_Descriptor.decConfigDescr.streamType << 2) | 0x01);
            decConfigBitstr.write24Bits(mES_Descriptor.decConfigDescr.bufferSizeDB);
            decConfigBitstr.write32Bits(mES_Descriptor.decConfigDescr.maxBitrate);
            decConfigBitstr.write32Bits(mES_Descriptor.decConfigDescr.avgBitrate);

            if (mES_Descriptor.decConfigDescr.decSpecificInfo.DecSpecificInfoTag == 5)
            {
                writeDecoderSpecificInfo(decConfigBitstr, mES_Descriptor.decConfigDescr.decSpecificInfo);
            }

            for (const auto& decSpecificInfo : mOtherDecSpecificInfo)
            {
                writeDecoderSpecificInfo(decConfigBitstr, decSpecificInfo);
            }

            decConfigSizeConverged = decConfigBitstr.getSize() == std::uint64_t(decConfigSize) + decConfigSizeSize;

            if (!decConfigSizeConverged)
            {
                decConfigSize = decConfigBitstr.getSize() - decConfigSizeSize;
            }
        }
        esBitstr.writeBitStream(decConfigBitstr);

        esSizeConverged = esBitstr.getSize() == std::uint64_t(esDescriptorSize) + esSizeSize;

        if (!esSizeConverged)
        {
            esDescriptorSize = std::uint32_t(esBitstr.getSize() - esSizeSize);
        }
    }
    bitstr.writeBitStream(esBitstr);
    updateSize(bitstr);
}
Beispiel #25
0
void pn::WindowManager::resize(bool fullscreen, unsigned width, unsigned height) {
	mm::setWindowSize(m_window, width, height);
	updateSize(fullscreen, width, height);
}
Beispiel #26
0
void Clock::paintInterface(QPainter *p, const QStyleOptionGraphicsItem *option, const QRect &contentsRect)
{
    Q_UNUSED(option);

    if (!m_time.isValid() || !m_date.isValid()) {
        return;
    }

    p->setPen(QPen(m_plainClockColor));
    p->setRenderHint(QPainter::SmoothPixmapTransform);
    p->setRenderHint(QPainter::Antialiasing);

    /* ... helps debugging contentsRect and sizing ...
       QColor c = QColor(Qt::blue);
       c.setAlphaF(.5);
       p->setBrush(c);
       p->drawRect(contentsRect);
     */

    // Paint the date, conditionally, and let us know afterwards how much
    // space is left for painting the time on top of it.
    QRectF dateRect;
    const QString timeString = KGlobal::locale()->formatTime(m_time, m_showSeconds);
    const QString fakeTimeString = KGlobal::locale()->formatTime(QTime(23,59,59), m_showSeconds);
    QFont smallFont = KGlobalSettings::smallestReadableFont();

    //create the string for the date and/or the timezone
    if (m_dateStyle || showTimezone()) {
        QString dateString;

        //Create the localized date string if needed
        if (m_dateStyle) {
            // JPL This needs a complete rewrite for l10n issues
            QString day = KGlobal::locale()->calendar()->formatDate(m_date, KLocale::Day, KLocale::ShortNumber);
            QString month = KGlobal::locale()->calendar()->formatDate(m_date, KLocale::Month, KLocale::LongNumber);

            if (m_dateStyle == 1) {         //compact date
                dateString = i18nc("@label Compact date: "
                        "%1 day in the month, %2 month number",
                        "%1/%2", day, month);
            } else if (m_dateStyle == 2) {    //short date
                dateString = KGlobal::locale()->formatDate(m_date, KLocale::ShortDate);
            } else if (m_dateStyle == 3) {    //long date
                dateString = KGlobal::locale()->formatDate(m_date, KLocale::LongDate);
            } else if (m_dateStyle == 4) {    //ISO date
                dateString = KGlobal::locale()->formatDate(m_date, KLocale::IsoDate);
            } else {                          //shouldn't happen
                dateString = KGlobal::locale()->formatDate(m_date, KLocale::ShortDate);
            }

            if (showTimezone()) {
                QString currentTimezone = prettyTimezone();
                dateString = i18nc("@label Date with currentTimezone: "
                        "%1 day of the week with date, %2 currentTimezone",
                        "%1 %2", dateString, currentTimezone);
            }
        } else if (showTimezone()) {
            dateString = prettyTimezone();
        }

        dateString = dateString.trimmed();

        if (m_dateString != dateString) {
            // If this string has changed (for example due to changes in the config
            // we have to reset the sizing of the applet
            m_dateString = dateString;
            updateSize();
        }

        // Check sizes
        // magic 10 is for very big spaces,
        // where there's enough space to grow without harming time space
        QFontMetrics fm(smallFont);

        if (contentsRect.height() > contentsRect.width() * 2) {
            //kDebug() << Plasma::Vertical << contentsRect.height() <<contentsRect.width() * 2;
            QRect dateRect = contentsRect;
            dateRect.setHeight(dateRect.width());
            smallFont.setPixelSize(qMax(dateRect.height() / 2, fm.ascent()));
            m_dateRect = preparePainter(p, dateRect, smallFont, dateString);
        } else {
            // Find a suitable size for the date font
            if (formFactor() == Plasma::Vertical) {
                smallFont.setPixelSize(qMax(contentsRect.height()/6, fm.ascent()));
            } else if (formFactor() == Plasma::Horizontal) {
                smallFont.setPixelSize(qMax(qMin(contentsRect.height(), contentsRect.width())*2/7, fm.ascent()));

                //we want to write the date always on one line
                fm = QFontMetrics(smallFont);
                const int tempWidth = fm.width(dateString);
                if(tempWidth > contentsRect.width()){
                    smallFont.setPixelSize((contentsRect.width() * smallFont.pixelSize())/tempWidth);
                }

            } else {
                smallFont.setPixelSize(qMax(qMin(contentsRect.height(), contentsRect.width())/8, KGlobalSettings::smallestReadableFont().pointSize()));
            }

            m_dateRect = preparePainter(p, contentsRect, smallFont, dateString);
        }

        // kDebug(96669) << "m_dateRect: " << m_dateRect;

        const int subtitleHeight = m_dateRect.height();
        const int subtitleWidth = m_dateRect.width();
        // kDebug(96669) << "subtitleWitdh: " << subtitleWitdh;
        // kDebug(96669) << "subtitleHeight: " << subtitleHeight;

        if (m_dateTimezoneBesides) {
            //kDebug(96669) << contentsRect.height() << subtitleHeight << smallFont.pixelSize();
            if (contentsRect.height() - subtitleHeight >= smallFont.pixelSize() || formFactor() != Plasma::Horizontal) {
                // to small to display the time on top of the date/timezone
                // put them side by side
                // kDebug(96669) << "switching to normal";
                m_dateTimezoneBesides = false;
                dateRect = normalLayout(subtitleWidth, subtitleHeight, contentsRect);
            } else {
                dateRect = sideBySideLayout(subtitleWidth, subtitleHeight, contentsRect);
            }
        } else {
            /* kDebug(96669) << "checking timezone placement"
                          << contentsRect.height() << dateRect.height() << subtitleHeight
                          << smallFont.pixelSize() << smallFont.pointSize();*/
            if (contentsRect.height() - subtitleHeight < smallFont.pixelSize() && formFactor() == Plasma::Horizontal) {
                // to small to display the time on top of the date/timezone
                // put them side by side
                // kDebug(96669) << "switching to s-b-s";
                m_dateTimezoneBesides = true;
                dateRect = sideBySideLayout(subtitleWidth, subtitleHeight, contentsRect);
            } else {
                dateRect = normalLayout(subtitleWidth, subtitleHeight, contentsRect);
            }
        }
    } else {
        m_timeRect = contentsRect;
    }
    // kDebug(96669) << "timeRect: " << m_timeRect;
    // p->fillRect(timeRect, QBrush(QColor("red")));

    // kDebug(96669) << m_time;
    // Choose a relatively big font size to start with
    m_plainClockFont.setPointSizeF(qMax(m_timeRect.height(), KGlobalSettings::smallestReadableFont().pointSize()));
    preparePainter(p, m_timeRect, m_plainClockFont, fakeTimeString, true);

    if (!m_dateString.isEmpty()) {
        if (m_dateTimezoneBesides) {
            QFontMetrics fm(m_plainClockFont);
            //kDebug() << dateRect << m_timeRect << fm.boundingRect(m_timeRect, Qt::AlignCenter, timeString);
            QRect br = fm.boundingRect(m_timeRect, Qt::AlignCenter, timeString);

            QFontMetrics smallfm(smallFont);
            dateRect.moveLeft(br.right() + qMin(0, br.left()) + smallfm.width(" "));
        }

        // When we're relatively low, force everything into a single line
        QFont f = p->font();
        p->setFont(smallFont);

        QPen datePen = p->pen();
        QColor dateColor = m_plainClockColor;
        dateColor.setAlphaF(0.7);
        datePen.setColor(dateColor);
        p->setPen(datePen);

        if (formFactor() == Plasma::Horizontal && (contentsRect.height() < smallFont.pointSize()*6)) {
            p->drawText(dateRect, Qt::TextSingleLine | Qt::AlignHCenter, m_dateString);
        } else {
            p->drawText(dateRect, Qt::TextWordWrap | Qt::AlignHCenter, m_dateString);
        }

        p->setFont(f);
    }

    if (m_useCustomColor || !m_svgExistsInTheme) {
        QFontMetrics fm(p->font());

        QPointF timeTextOrigin(QPointF(qMax(0, (m_timeRect.center().x() - fm.width(fakeTimeString) / 2)),
                            (m_timeRect.center().y() + fm.height() / 3)));
        p->translate(-0.5, -0.5);

        if (m_drawShadow) {
            QPen tmpPen = p->pen();

            // Paint a backdrop behind the time's text
            qreal shadowOffset = 1.0;
            QPen shadowPen;
            QColor shadowColor = m_plainClockShadowColor;
            shadowColor.setAlphaF(.4);
            shadowPen.setColor(shadowColor);
            p->setPen(shadowPen);
            QPointF shadowTimeTextOrigin = QPointF(timeTextOrigin.x() + shadowOffset,
                                                timeTextOrigin.y() + shadowOffset);
            p->drawText(shadowTimeTextOrigin, timeString);

            p->setPen(tmpPen);

            // Paint the time itself with a linear translucency gradient
            QLinearGradient gradient = QLinearGradient(QPointF(0, 0), QPointF(0, fm.height()));

            QColor startColor = m_plainClockColor;
            startColor.setAlphaF(.95);
            QColor stopColor = m_plainClockColor;
            stopColor.setAlphaF(.7);

            gradient.setColorAt(0.0, startColor);
            gradient.setColorAt(0.5, stopColor);
            gradient.setColorAt(1.0, startColor);
            QBrush gradientBrush(gradient);

            QPen gradientPen(gradientBrush, tmpPen.width());
            p->setPen(gradientPen);
        }
        p->drawText(timeTextOrigin, timeString);
    //when use the custom theme colors, draw the time textured
    } else {
        QRect adjustedTimeRect = m_pixmap.rect();
        adjustedTimeRect.moveCenter(m_timeRect.center());
        p->drawPixmap(adjustedTimeRect, m_pixmap);
    }
}
Beispiel #27
0
	void setSize(int xSize, int ySize)
	{
		MoveWindow(windowHandle, xPosition, yPosition, xSize, ySize, TRUE);
		updateSize();
	}
void QtWaitingSpinner::setLength(int length){
	myLength = length;
	updateSize();
}
Beispiel #29
0
IntSize BitmapImage::sizeRespectingOrientation() const
{
    updateSize();
    return m_sizeRespectingOrientation;
}
void QtWaitingSpinner::setWidth(int width) {
	myWidth = width;
	updateSize();
}