Пример #1
0
    void SetSize(int rows, int columns)
    {
        m_vvstr.SetCount(rows);
        m_vcolor.SetCount(rows);
        m_vColumn.SetCount(columns);

        for (int index = 0; index < rows; index++) {
            m_vvstr.Get(index).SetCount(columns);
        }

        Changed();
    }
Пример #2
0
    PaletteImpl(IDirectDrawPaletteX* pddpal) :
        m_pddpal(pddpal)
    {
        DWORD caps;

        DDCall(m_pddpal->GetCaps(&caps));

        int count;

        if (caps & DDPCAPS_4BIT) {
            count = 16;
        } else if (caps & DDPCAPS_8BIT) {
            count = 256;
        } else {
            ZError("Unsupported palette size");
        }

        PALETTEENTRY ppe[256];
        DDCall(m_pddpal->GetEntries(0, 0, count, ppe));

        m_pcolors.SetCount(count);
        for (int index = 0; index < count; index++) {
            float scale = (1.0f / 255);

            m_pcolors.Set(
                index,
                Color(
                    ppe[index].peRed   / 255.0f,
                    ppe[index].peGreen / 255.0f,
                    ppe[index].peBlue  / 255.0f
                )
            );
        }
    }
Пример #3
0
    void EliminateModes(const WinPoint& size)
    {
        int count = m_modes.GetCount();

        for(int index = 0; index < count; index++) {
            if (
                   m_modes[index].X() >= size.X() 
                && m_modes[index].Y() >= size.Y() 
            ) {
                m_modes.SetCount(index);
                return;
            }
        }
    }
void Matrix::Transform(const TVector<Point>& vSource, TVector<Point>& vDest) const
{
    int count = vSource.GetCount();
    vDest.SetCount(count);

    for (int index = 0; index < count; index++) {
        float x = vSource[index].X();
        float y = vSource[index].Y();

        vDest.Set(
            index,
            Point(
                m_m[0][0] * x + m_m[0][1] * y + m_m[0][3],
                m_m[1][0] * x + m_m[1][1] * y + m_m[1][3]
            )
        );
    }
}
    void SetCount(unsigned int seed, short count)
    {
        count = count * 4;
        m_data.SetCount(count);

        srand(seed);

        for (int index = 0; index < count; index++) {
            //
            // Allocate star positions with a nice uniform density
            //

            StarData& data = m_data.Get(index);

            data.m_direction = Vector::RandomDirection();
            data.m_bFirstFrame = true;

            float bright = random(0.25f, 1);

            data.m_color = Color(bright, bright, bright);
        }
    }
//    JoystickInputStreamImpl(IDirectInputDevice2* pdid, HWND hwnd) :
	JoystickInputStreamImpl(IDirectInputDevice7* pdid, HWND hwnd) :		// mdvalley: DInput7
        m_pdid(pdid),
        m_bFocus(false),
        m_vvalueObject(5)
    {
        DDCall(m_pdid->GetCapabilities(&m_didc));
        DDCall(m_pdid->GetDeviceInfo(&m_didi));

        //
        // Enumerate the buttons and values
        //

        DDCall(m_pdid->EnumObjects(StaticEnumObjectsCallback, this, DIDFT_ALL));

        //
        // Remove any holes in the value vector
        //

        int index;
        int countValues = m_vvalueObject.GetCount();

        index = 0;
        while (index < countValues) {
            if (m_vvalueObject[index] == NULL) {
                if (index != countValues - 1) {
                    m_vvalueObject.Set(index, m_vvalueObject[countValues - 1]);
                }

                countValues--;
                m_vvalueObject.SetCount(countValues);
            } else {
                index++;
            }
        }

        //
        // Build the data format
        //

        int countButtons = m_vbuttonObject.GetCount();

        m_sizeData  = NextMultipleOf(4, countValues * 4 + countButtons * 1);

        DIDataFormat didf;

        didf.dwObjSize  = sizeof(DIOBJECTDATAFORMAT);
        didf.dwFlags    = 0;
        didf.dwDataSize = m_sizeData;
        didf.dwNumObjs  = countValues + countButtons;

        DIObjectDataFormat* pdiodf = new DIObjectDataFormat[didf.dwNumObjs];
        didf.rgodf      =  pdiodf;

        for (index = 0; index < countValues; index++) {
            ValueDDInputObject* pobject = m_vvalueObject[index];
            DIOBJECTDATAFORMAT& diodf   = didf.rgodf[index];

            diodf.pguid   = (GUID*)&(pobject->GetGUID());
            diodf.dwOfs   = index * 4;
            diodf.dwType  = pobject->GetDWType();
            diodf.dwFlags = DIDOI_ASPECTPOSITION;
        }

        for (index = 0; index < countButtons; index++) {
            ButtonDDInputObject* pobject = m_vbuttonObject[index];
            DIOBJECTDATAFORMAT&  diodf   = didf.rgodf[countValues + index];

            diodf.pguid   = (GUID*)&(pobject->GetGUID());
            diodf.dwOfs   = countValues * 4 + index;
            diodf.dwType  = pobject->GetDWType();
            diodf.dwFlags = DIDOI_ASPECTPOSITION;
        }

        DDCall(m_pdid->SetDataFormat(&didf));

        delete pdiodf;

        //
        // Allocate a data receptical
        //

        m_pbyteData = new BYTE[m_sizeData];

        //
        // We only need joystick input when we are in the foreground
        //

        DDCall(m_pdid->SetCooperativeLevel(hwnd, DISCL_EXCLUSIVE | DISCL_FOREGROUND));

        //
        // Set ranges
        //

        SetRanges();
    }
Пример #7
0
    void VerifyScrollPos()
    {
        if (m_bNeedScrollUpdate) {
            m_bNeedScrollUpdate = false;

            if (m_bNeedSelectionOnScreen) {
                m_bNeedSelectionOnScreen = false;

                //
                // Figure out where the selection is
                //

                int nItemSize  = GetSignificantSize(*m_ppainter);
                int ySelection = m_indexSelection * nItemSize - GetScrollPos();

                //
                // Make sure the selection is in the window
                //
 
                if (ySelection + GetSignificantSize(*m_ppainter) >= GetSignificantSize()) {
                    ySelection = GetSignificantSize() - GetSignificantSize(*m_ppainter);
                }
     
                if (ySelection <  0) {
                    ySelection = 0;
                }
 
                 //
                // Adjust the scroll bar so that the selection doesn't move
                //
     
                if (m_pscroll && m_plist->GetCount() * GetSignificantSize(*m_ppainter) > GetSignificantSize()) {
                    SetScrollPos(m_indexSelection * GetSignificantSize(*m_ppainter) - ySelection);
                } else {
                    SetScrollPos(0);
                }
            } else {
                //
                // find the top item in the old list
                //

                int nItemSize = GetSignificantSize(*m_ppainter);
                int iOldTop   = GetScrollPos() / nItemSize;

                //
                // use the selected item as the basis if it was visible, otherwise use 
                // the top item
                //

                int nLinesPerScreen = GetSignificantSize() / nItemSize;
                int iOldBasis;

                if (
                       m_iOldSelection >= iOldTop 
                    && m_iOldSelection <  iOldTop + nLinesPerScreen
                ) {
                    //
                    // visible
                    //

                    iOldBasis = m_iOldSelection;
                } else {
                    iOldBasis = iOldTop;
                }

                //
                // get the scroll offset from the basis to the top, so we can try 
                // to keep the basis perfectly stable.
                //

                int nTopFromBasis = GetScrollPos() - iOldBasis * nItemSize;

                //
                // find the new basis...
                //

                int iNewBasis = FindNearestNewIndex(iOldBasis);

                //
                // set the scroll position relative to the new basis
                //

                SetScrollPos(iNewBasis * nItemSize + nTopFromBasis);
            }

            //
            // update m_vectItemsOld to contain the new contents
            //

            int nNewCount = m_plist->GetCount();

            m_vectItemsOld.SetCount(nNewCount);

            for (int i = 0; i < nNewCount; i++) {
                m_vectItemsOld.Set(i, m_plist->GetItem(i));
            }

            m_iOldSelection = m_indexSelection;
        }
    }