Logo Search packages:      
Sourcecode: vdr-plugin-sudoku version File versions  Download package

void Menu::paint (  )  [private]

Paint all pieces of the menu.

Definition at line 160 of file menu.cpp.

References Sudoku::Puzzle::ambiguous(), Sudoku::Pos::col(), Sudoku::Puzzle::error(), Sudoku::Numbers::get(), Sudoku::Puzzle::given(), SudokuPlugin::SetupData::mark_ambiguous, SudokuPlugin::SetupData::mark_errors, Sudoku::Puzzle::marked(), Sudoku::Pos::row(), SudokuPlugin::Bitmap::text(), and SudokuPlugin::SetupData::transparency.

Referenced by ProcessKey(), and Show().

{
  int trans = setup.transparency;
  tColor fg, bg = TRANS(GRID_COLOR, trans);
  int x1 = xPos,                 y1 = yPos;
  int x2 = xPos + GRID_SIZE - 1, y2 = yPos + GRID_SIZE -1;

  // Save and restore palette to reduce flickering.
  cPalette savePalette(*osd->GetBitmap(0));
  osd->DrawRectangle(x1, y1, x2, y2, bg);
  osd->SetPalette(savePalette, 0);

  // Paint all cells.
  for (Pos p = Pos::first(); p <= Pos::last(); p = p.next())
  {
    fg = NUMBER_FG, bg = NUMBER_BG;
    if (puzzle.given(p))
      fg = GIVEN_FG, bg = GIVEN_BG;
    else if (puzzle.marked(p))
      fg = MARKED_FG, bg = MARKED_BG;
    else if (setup.mark_errors && puzzle.error(p))
      fg = ERROR_FG, bg = ERROR_BG;
    else if (setup.mark_ambiguous && puzzle.ambiguous(p))
      fg = AMBIG_FG, bg = AMBIG_BG;
    fg = TRANS(fg, trans);
    bg = TRANS(bg, trans);

    // Paint the background of the cell.
    x1 = xPos + CELL_POS(p.col()), y1 = yPos + CELL_POS(p.row());
    x2 = x1   + CELL_SIZE - 1,     y2 = y1   + CELL_SIZE - 1;
    osd->DrawRectangle(x1, y1, x2, y2, bg);

    // Paint the content of the cell.
    if (puzzle.get(p) != 0)
    {
      char txt[2] = { '0' + puzzle.get(p), 0 };
      const cFont* font = cFont::GetFont(fontFix);
      osd->DrawText(x1, y1, txt, fg, bg, font, CELL_SIZE, CELL_SIZE, taCenter);
    }
  }

  // Paint the cursor.
  bg = TRANS(CURSUR_COLOR, trans);
  x1 = xPos + CELL_POS(curr.col()), y1 = yPos + CELL_POS(curr.row());
  x2 = x1   + CELL_SIZE - 1,        y2 = y1   + CELL_SIZE - 1;
  osd->DrawRectangle(x1 - 5, y1 - 5, x2,     y1,     bg);
  osd->DrawRectangle(x1 - 5, y1,     x1,     y2 + 5, bg);
  osd->DrawRectangle(x1,     y2,     x2 + 5, y2 + 5, bg);
  osd->DrawRectangle(x2,     y1 - 5, x2 + 5, y2,     bg);

  // Paint info window.
  if (infoText)
  {
    if (!info)
      info = new Bitmap(GRID_SIZE - 20, 60);
    info->text(infoText);
    osd->DrawBitmap(xPos + 10, yPos + 10, *info);
    infoText = NULL;
  }

  osd->Flush();
}


Generated by  Doxygen 1.6.0   Back to index