// Scale a bitmap. In UK MHEG this is only used for MPEG I-frames, not PNG. void MHBitmap::ScaleBitmap(int xScale, int yScale, MHEngine *engine) { QRegion updateArea = GetVisibleArea(); // If there's any content already we have to redraw it. m_pContent->ScaleImage(xScale, yScale); updateArea += GetVisibleArea(); // Redraw this bitmap. engine->Redraw(updateArea); // Mark for redrawing }
// Decode the content. void MHBitmap::ContentArrived(const unsigned char *data, int length, MHEngine *engine) { QRegion updateArea = GetVisibleArea(); // If there's any content already we have to redraw it. if (! m_pContent) return; // Shouldn't happen. int nCHook = m_nContentHook; if (nCHook == 0) nCHook = engine->GetDefaultBitmapCHook(); // TODO: What if we can't convert it? if (nCHook == 4) { // PNG. m_pContent->CreateFromPNG(data, length); } // CHook 5 seems to be used by the BBC on Freesat for an MPEG I-frame for the // background but enabling it here results in it overlaying the video. // Presumably it is not simply the same as CHook 2. else if (nCHook == 2 /* ||nCHook == 5 */) { // MPEG I-frame. m_pContent->CreateFromMPEG(data, length); } else MHERROR(QString("Unknown bitmap content hook %1").arg(nCHook)); updateArea += GetVisibleArea(); // Redraw this bitmap. engine->Redraw(updateArea); // Mark for redrawing // Now signal that the content is available. engine->EventTriggered(this, EventContentAvailable); }
void MHVisible::SetBoxSize(int nWidth, int nHeight, MHEngine *engine) { QRegion drawRegion = GetVisibleArea(); m_nBoxWidth = nWidth; m_nBoxHeight = nHeight; drawRegion += GetVisibleArea(); engine->Redraw(drawRegion); }
// Added action in UK MHEG. void MHVideo::SetVideoDecodeOffset(int newXOffset, int newYOffset, MHEngine *engine) { QRegion updateArea = GetVisibleArea(); // Redraw the area before the offset m_nXDecodeOffset = newXOffset; m_nYDecodeOffset = newYOffset; updateArea += GetVisibleArea(); // Redraw the resulting area. engine->Redraw(updateArea); // Mark for redrawing }
// Added action in UK MHEG. void MHBitmap::SetBitmapDecodeOffset(int newXOffset, int newYOffset, MHEngine *engine) { QRegion updateArea = GetVisibleArea(); // Redraw the area before the offset m_nXDecodeOffset = newXOffset; m_nYDecodeOffset = newYOffset; updateArea += GetVisibleArea(); // Redraw this bitmap. engine->Redraw(updateArea); // Mark for redrawing }
void MHVideo::ScaleVideo(int xScale, int yScale, MHEngine *engine) { if (xScale == m_nDecodeWidth && yScale == m_nDecodeHeight) return; QRegion updateArea = GetVisibleArea(); // Redraw the area before the offset m_nDecodeWidth = xScale; m_nDecodeHeight = yScale; updateArea += GetVisibleArea(); // Redraw this bitmap. engine->Redraw(updateArea); // Mark for redrawing }
// MHEG actions. void MHVisible::SetPosition(int nXPosition, int nYPosition, MHEngine *engine) { // When we move a visible we have to redraw both the old area and the new. // In some cases, such as moving an opaque rectangle we might be able to reduce // this if there is some overlap. QRegion drawRegion = GetVisibleArea(); m_nPosX = nXPosition; m_nPosY = nYPosition; drawRegion += GetVisibleArea(); engine->Redraw(drawRegion); }
void MHText::SetBackgroundColour(const MHColour &colour, MHEngine *engine) { m_bgColour.Copy(colour); // Setting the background colour doesn't affect the text image but we have to // redraw it onto the display. engine->Redraw(GetVisibleArea()); }
void MHText::CreateContent(const unsigned char *p, int s, MHEngine *engine) { m_Content.Copy(MHOctetString((const char *)p, s)); engine->Redraw(GetVisibleArea()); // Have to redraw if the content has changed. m_fNeedsRedraw = true; // fprintf(fd, "Text content is now "); m_Content.PrintMe(0); fprintf(fd, "\n"); }
void MHVisible::Activation(MHEngine *engine) { if (m_fRunning) return; MHIngredient::Activation(engine); m_fRunning = true; engine->Redraw(GetVisibleArea()); // Display the visible. engine->EventTriggered(this, EventIsRunning); }
void MHSlider::Increment(MHEngine *engine) { if (slider_value + step_size <= max_value) { slider_value += step_size; engine->Redraw(GetVisibleArea()); engine->EventTriggered(this, EventSliderValueChanged); } }
void MHSlider::Decrement(MHEngine *engine) { if (slider_value - step_size >= min_value) { slider_value -= step_size; engine->Redraw(GetVisibleArea()); engine->EventTriggered(this, EventSliderValueChanged); } }
void MHVisible::Deactivation(MHEngine *engine) { if (! m_fRunning) return; // Stop displaying. We need to save the area before we turn off m_fRunning but // only call Redraw once this is no longer visible so that the area beneath will be drawn. QRegion region = GetVisibleArea(); MHIngredient::Deactivation(engine); engine->Redraw(region); // Draw underlying object. }
void MHSlider::SetPortion(int newPortion, MHEngine *engine) { portion = newPortion; if (m_fRunning) { engine->Redraw(GetVisibleArea()); } engine->EventTriggered(this, EventSliderValueChanged); }
void MHSlider::SetSliderValue(int newValue, MHEngine *engine) { slider_value = newValue; if (m_fRunning) { engine->Redraw(GetVisibleArea()); } engine->EventTriggered(this, EventSliderValueChanged); }
void MHSlider::Step(int nbSteps, MHEngine *engine) { step_size = nbSteps; if (m_fRunning) { engine->Redraw(GetVisibleArea()); } engine->EventTriggered(this, EventSliderValueChanged); }
// Additional action defined in UK MHEG. void MHSlider::SetSliderParameters(int newMin, int newMax, int newStep, MHEngine *engine) { min_value = newMin; max_value = newMax; step_size = newStep; slider_value = newMin; if (m_fRunning) { engine->Redraw(GetVisibleArea()); } engine->EventTriggered(this, EventSliderValueChanged); }
// Called when the interaction has been terminated and we need // to restore the state to non-interacting. void MHSlider::InteractionCompleted(MHEngine *engine) { MHInteractible::InteractionCompleted(engine); // Redraw with the interaction highlighting turned off engine->Redraw(GetVisibleArea()); }
void MHLineArt::SetLineStyle(int nStyle, MHEngine *engine) { m_LineStyle = nStyle; engine->Redraw(GetVisibleArea()); }
void MHLineArt::SetLineWidth(int nWidth, MHEngine *engine) { m_nLineWidth = nWidth; engine->Redraw(GetVisibleArea()); }
void MHLineArt::SetLineColour(const MHColour &colour, MHEngine *engine) { m_LineColour.Copy(colour); engine->Redraw(GetVisibleArea()); }
void MHVisible::SetPaletteRef(const MHObjectRef newPalette, MHEngine *engine) { m_PaletteRef.Copy(newPalette); engine->Redraw(GetVisibleArea()); }
void MHText::SetTextColour(const MHColour &colour, MHEngine *engine) { m_textColour.Copy(colour); m_fNeedsRedraw = true; engine->Redraw(GetVisibleArea()); }
void MHText::SetFontAttributes(const MHOctetString &fontAttrs, MHEngine *engine) { m_fontAttrs.Copy(fontAttrs); m_fNeedsRedraw = true; engine->Redraw(GetVisibleArea()); }
// Return the area actually obscured by the bitmap. QRegion MHBitmap::GetOpaqueArea() { // The area is empty unless the bitmap is opaque. if (! m_fRunning || m_pContent == NULL || ! m_pContent->IsOpaque()) return QRegion(); else return GetVisibleArea(); }