Esempio n. 1
0
// prints the static canvas and the floating brick dynamically
void printTetrisBucket() {
  int i, j, k, l, m, open = 1;

  verifyWClear(bucketWin);
  wprintw(bucketWin, "\n");

  for (i = 0; i < tetrisBucket.height; i++) {
    wprintw(bucketWin, "<!");
    for (j = 0; j < tetrisBucket.width; j++) {
      int valid = 0;

      for (m = 0; m < currentbrick->size; m++) {
        if (currentbrick->visualRepresentation[m][0].y == i) {
          valid = 1;
        }
      }

      if (valid) {
        for (k = 0; k < currentbrick->size; k++) {
          if (currentbrick->visualRepresentation[k][0].y == i) {
            for (l = 0; l < currentbrick->size; l++) {
              if (currentbrick->visualRepresentation[k][l].x == j &&
                      currentbrick->visualRepresentation[k][l].value == 1) {
                wattr_on(bucketWin, currentbrick->color, NULL);
                wprintw(bucketWin, "%c", '#');
                wattr_on(bucketWin, COLOR_PAIR(1), NULL);
                open = 0;
              }
            }
          }
        }
      }

      if (open) {
        wattr_on(bucketWin, tetrisBucket.bucket[i][j].color, NULL);
        wprintw(bucketWin, "%c", tetrisBucket.bucket[i][j]);
        wattr_on(bucketWin, COLOR_PAIR(1), NULL);
      } else {
        open = 1;
      }
    }
    wprintw(bucketWin, "!>\n");
  }

  wprintw(bucketWin, "<!");

  for (i = 0; i < tetrisBucket.width; i++) {
    wprintw(bucketWin, "=");
  }
  wprintw(bucketWin, "!>\n  ");

  for (i = 0; i < tetrisBucket.width; i++) {
    wprintw(bucketWin, "^");
  }
  wprintw(bucketWin, "\n");

  verifyWRefresh(bucketWin);
}
Esempio n. 2
0
// updates the tetrisbucket and brick, is only called when canvas is changed
void updateBucketWindow() {
  int i, j, m, k, l, open = 1;

  for (i = 0; i < tetrisBucket.height; i++) {
    verifyWMove(bucketWin, 1 + i, 2);
    for (j = 0; j < tetrisBucket.width; j++) {
      int valid = 0;

      for (m = 0; m < currentbrick->size; m++) {
        if (currentbrick->visualRepresentation[m][0].y == i) {
          valid = 1;
        }
      }

      if (valid) {
        for (k = 0; k < currentbrick->size; k++) {
          if (currentbrick->visualRepresentation[k][0].y == i) {
            for (l = 0; l < currentbrick->size; l++) {
              if (currentbrick->visualRepresentation[k][l].x == j &&
                      currentbrick->visualRepresentation[k][l].value == 1) {
                wattr_on(bucketWin, currentbrick->color, NULL);
                verifyWMove(bucketWin, 1 + i, 2 + j);
                wprintw(bucketWin, "%c", '#');
                wattr_on(bucketWin, COLOR_PAIR(1), NULL);
                open = 0;
                break;
              }
            }
          }

          if (!open) {
            break;
          }
        }
      }

      if (open) {
        wattr_on(bucketWin, tetrisBucket.bucket[i][j].color, NULL);
        verifyWMove(bucketWin, 1 + i, 2 + j);
        wprintw(bucketWin, "%c", tetrisBucket.bucket[i][j]);
        wattr_on(bucketWin, COLOR_PAIR(1), NULL);
      } else {
        open = 1;
      }
    }
  }
  verifyWRefresh(bucketWin);
}
Esempio n. 3
0
int
attr_on(attr_t at, void *opts)
{
	(void) wattr_on(stdscr, at, opts);

	return (OK);
}
Esempio n. 4
0
// updates the nextBrick window
void updateNextBrickWindow() {
  int i, j;

  verifyWMove(nextBrickWin, 3, 0);
  for (i = 0; i < nextBrick->size; i++) {
    wprintw(nextBrickWin, "|%s", "   ");
    for (j = 0; j < nextBrick->size; j++) {
      if (nextBrick->visualRepresentation[i][j].value == 1) {
        wattr_on(nextBrickWin, nextBrick->color, NULL);
        wprintw(nextBrickWin, "%c", '#');
        wattr_on(nextBrickWin, COLOR_PAIR(1), NULL);
      } else {
        wprintw(nextBrickWin, "%c", ' ');
      }
    }
    wprintw(nextBrickWin, "%s|\n", "   ");
  }
  verifyWRefresh(nextBrickWin);
}
Esempio n. 5
0
void lynx_standout( int flag )
{
  if ( flag )
  {
    wattr_on( LYwin, 262144, 0 );
  }
  else
  {
    wattr_off( LYwin, 262144, 0 );
  }
  return;
}
Esempio n. 6
0
int
slk_attr_on(const attr_t at, void *opts)
{
	int code = ERR;

#ifdef M_CURSES_TRACE
	__m_trace("slk_attr_on(%x, %p)", at, opts);
#endif

	if (__m_screen->_slk._w != (WINDOW *) 0)
		code = wattr_on(__m_screen->_slk._w, at, opts);

	return __m_return_code("slk_attr_on", code);
}
Esempio n. 7
0
// displays the upcoming brick right of the bucket
void printNextBrickWindow() {
  verifyWClear(nextBrickWin);
  int i, j;

  wprintw(nextBrickWin, "%s\n\n", " Next Brick:");
  wprintw(nextBrickWin, "+%s+\n", " --------- ");

  for (i = 0; i < nextBrick->size; i++) {
    wprintw(nextBrickWin, "|%s", "   ");
    for (j = 0; j < nextBrick->size; j++) {
      if (nextBrick->visualRepresentation[i][j].value == 1) {
        wattr_on(nextBrickWin, nextBrick->color, NULL);
        wprintw(nextBrickWin, "%c", '#');
        wattr_on(nextBrickWin, COLOR_PAIR(1), NULL);
      } else {
        wprintw(nextBrickWin, "%c", ' ');
      }
    }
    wprintw(nextBrickWin, "%s|\n", "   ");
  }
  wprintw(nextBrickWin, "+%s+\n", " --------- ");

  verifyWRefresh(nextBrickWin);
}
Esempio n. 8
0
Point CursesWindow::putCh(int ch, const Point & pos, int color, int attr, bool preserveOldLoc)
{
  int x = pos.x(), y = pos.y();
  wstandend(m_win);
  if (!color) color = defaultColor();
  if (color) wcolor_set(m_win, color, 0);
  if (attr) wattr_on(m_win, attr, 0);
  int oldy, oldx;
  getyx(m_win, oldy, oldx);
  if (pos.isNull()) y = oldy;
  if (pos.isNull()) x = oldx;
  if (y < 0) y = oldy+y;
  if (x < 0) x = oldx+x;
  wmove(m_win, y, x);
  waddch(m_win, ch);
  if (preserveOldLoc)
    wmove(m_win, oldy, oldx);
  wstandend(m_win);  
  return curs();
}
Esempio n. 9
0
// called when brick has moved or rotated, so as not to update the entire canvas
void updateBrick() {
  int k, l, y, x;

  for (k = 0; k < currentbrick->size; k++) {
    y = currentbrick->visualRepresentation[k][0].y;
    if (y >= 0 && y < tetrisBucket.height) {
      for (l = 0; l < currentbrick->size; l++) {
        x = currentbrick->visualRepresentation[k][l].x;
        if (x >= 0 && x < tetrisBucket.width) {
          verifyWMove(bucketWin, y + 1, x + 2);

          if (currentbrick->visualRepresentation[k][l].value == 1) {
            wattr_on(bucketWin, currentbrick->color, NULL);
            wprintw(bucketWin, "%c", '#');

            // writes trailing char in width if full brick
            if (l == currentbrick->size - 1 && x < tetrisBucket.width - 1) {
              wattr_on(bucketWin, tetrisBucket.bucket[y][x + 1].color, NULL);
              wprintw(bucketWin, "%c", tetrisBucket.bucket[y][x + 1]);
            } else if (l == 0 && x > 0) {
              verifyWMove(bucketWin, y + 1, x + 1);
              wattr_on(bucketWin, tetrisBucket.bucket[y][x - 1].color, NULL);
              wprintw(bucketWin, "%c", tetrisBucket.bucket[y][x - 1]);
            }
          } else {
            // writes canvas if value 0
            wattr_on(bucketWin, tetrisBucket.bucket[y][x].color, NULL);
            wprintw(bucketWin, "%c", tetrisBucket.bucket[y][x]);
          }
        }

        // writes trailing char in height if full brick
        if (k == 0 ) {
        if (currentbrick->visualRepresentation[k][l].value == 1 && y > 0) {
          int tempY = currentbrick->visualRepresentation[k][l].y - 1;
          verifyWMove(bucketWin, tempY + 1, x + 2);
            wattr_on(bucketWin, tetrisBucket.bucket[tempY][x].color, NULL);
            wprintw(bucketWin, "%c", tetrisBucket.bucket[tempY][x]);
          }
        }
      }
    }
  }
  wattr_on(bucketWin, COLOR_PAIR(1), NULL);
  verifyWRefresh(bucketWin);
}
Esempio n. 10
0
void lynx_start_reverse( void )
{
  wattr_on( LYwin, 262144, 0 );
  return;
}
Esempio n. 11
0
NCURSES_EXPORT(int) (attr_on) (attr_t a1, void * z)
{
	T((T_CALLED("attr_on(%s,%p)"), _traceattr2(0,a1), (const void *)z)); returnCode(wattr_on(stdscr,a1,z));
}
Esempio n. 12
0
NCURSES_EXPORT(int) (wattron) (WINDOW * a1, int z)
{
	T((T_CALLED("wattron(%p,%d)"), (const void *)a1, z)); returnCode(wattr_on(a1, (attr_t)(z), ((void *)0)));
}
Esempio n. 13
0
void CTabWidget::update(int c)
{
	if(_visible)
	{
		move_panel(_panel, _pos.y(), _pos.x());
		//top_panel(_panel);
		wclear(_window);

		if(_listenKeys)
		{
			if(c == KEY_LEFT)
			{
				if(currentIndex() - 1 >= 0)
					setCurrentIndex(currentIndex() - 1);
				else
					setCurrentIndex(count() - 1);
			}
			else if(c == KEY_RIGHT)
			{
				if(currentIndex() + 1 < int(count()))
					setCurrentIndex(currentIndex() + 1);
				else
					setCurrentIndex(0);
			}
		}

		uint tw = _size.width() - _leftMargin - _rightMargin;

		// Is left mouse button pressed?
#ifdef __PDCURSES__
		bool leftClick = focused() && Mouse_status.button[0] == BUTTON_PRESSED;
#else
		bool leftClick = false;
		MEVENT event;
		if(getmouse(&event) == OK)
			leftClick = focused() && (event.bstate & BUTTON1_PRESSED);
#endif

		int k = 0;
		for(uint i = 0; i < _widgets.size(); ++i)
		{
			if(leftClick)
			{
				if(_mousePos.x() >= _pos.x() + _leftMargin + k &&
				   _mousePos.x() < _pos.x() + _leftMargin + k + _widgets[i]->name().size() &&
				   _mousePos.y() == (_bottom ? _pos.y() + _size.height() - 1 : _pos.y()))
				{
					// select tab
					setCurrentIndex(i);
				}
			}

			if(currentIndex() == i)
				wattr_on(_window, A_BOLD, 0);

			mvwaddstr(_window, _bottom ? _size.height() - 1 : 0, _leftMargin + k, _widgets[i]->name().c_str());

			if(_currentIndex == i)
				wattr_off(_window, A_BOLD, 0);

			k += _widgets[i]->name().size() + 1;
		}

		if(_layout)
		{
			if(_changed)
			{
				DEBUG_ui("CTabWidget::update, 0");
				_layout->setSize(_size.width(), _size.height() - 1);
				_layout->setPosition(_pos.x(), _bottom ? _pos.y() : _pos.y() + 1);
				_changed = false;
				DEBUG_ui("CTabWidget::update, 1");
			}

			_layout->update(c);
		}
	}
}
Esempio n. 14
0
void lynx_start_underline( void )
{
  wattr_on( LYwin, 131072, 0 );
  return;
}
Esempio n. 15
0
NCURSES_EXPORT(int) (attron) (int z)
{
	T((T_CALLED("attron(%s)"), _traceattr2(0,(chtype)z)));
	returnCode(wattr_on(stdscr, (attr_t)((z)), ((void *)0)));
}
Esempio n. 16
0
void CListWidget::update(int c)
{
	if(_visible)
	{
		uint tw = _size.width();
		uint th = _size.height();

		if(focused())
		{		
#ifdef __PDCURSES__
			// Mouse wheel scrolling
			if(c == KEY_MOUSE && _count > th)
			{
				if(Mouse_status.changes == MOUSE_WHEEL_DOWN)
				{
					_scroll += 4;
					_changed = true;
				}
				else if(Mouse_status.changes == MOUSE_WHEEL_UP && _scroll >= 4)
				{
					_scroll -= 4;
					_changed = true;
				}
			}
#endif
		}

		if((_listenKeys || focused()) && _count > th)
		{
			if(c == KEY_NPAGE)	// PAGE DOWN
			{
				_scroll += 4;
				_changed = true;
			}
			else if(c == KEY_PPAGE && _scroll >= 4)	// PAGE UP
			{
				_scroll -= 4;
				_changed = true;
			}
		}

		if(_changed)
		{
			move_panel(_panel, _pos.y(), _pos.x());
			top_panel(_panel);
			wclear(_window);

			if((_count < th && _scroll < _count) || (_count > th && _scroll > _count)) _scroll = _count;
			if(_count > th && _scroll < th) _scroll = th;

			uint b = 0, n = 0;

			for(uint i = 0; i < _items.size() && i < _scroll + b; ++i)
			{
				if(_items[i]->nocrlf()) b++;

				if(!_items[i]->nocrlf())
					n = 0;

				const string &message = _items[i]->text();

				for(uint j = 0; j < _leftMargin; ++j)
					waddch(_window, ' ');

				attr_t a = attribute(_items[i]->backgroundColor(), _items[i]->foregroundColor(), _items[i]->bold());
				wattr_on(_window, a, 0);

				n++;

				for(uint j = 0; j < message.size(); ++j, n++)
				{
					if(n >= tw - _leftMargin - _rightMargin)
					{
						n = 0;
						wattr_off(_window, a, 0);
						waddch(_window, '\n');
						for(uint j = 0; j < _leftMargin; ++j)
							waddch(_window, ' ');
						wattr_on(_window, a, 0);
					}

					waddch(_window, toULong(message[j]));
				}

				wattr_off(_window, a, 0);

				if(i < _scroll + b - 1 && i != _items.size() - 1 && !_items[i]->nocrlf())
					waddch(_window, '\n');
			}

			_changed = false;
		}
	}
}
Esempio n. 17
0
void lynx_start_bold( void )
{
  wattr_on( LYwin, 2097152, 0 );
  return;
}