/**
 * @brief Parse a @a decoration definition.
 *
 *        Syntax: decoration=enable|disable
 *
 * @param in definition to be analyzed
 *
 * @return 0 (ok) or 1 (error)
 */
static int item_decoration(char *in)
{
    if (!window_item("decoration"))
        return 1;

    if (in_window("video"))
        return 1;
    if (in_window("playbar"))
        return 1;
    if (in_window("menu"))
        return 1;

    strlower(in);

    if (strcmp(in, "enable") != 0 && strcmp(in, "disable") != 0) {
        skin_error(MSGTR_SKIN_UnknownParameter, in);
        return 1;
    }

    skin->mainDecoration = (strcmp(in, "enable") == 0);

    mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin]    decoration: %s\n", in);

    return 0;
}
/**
 * @brief Parse a @a selected definition.
 *
 *        Syntax: selected=image
 *
 * @param in definition to be analyzed
 *
 * @return 0 (ok) or 1 (error)
 */
static int item_selected(char *in)
{
    unsigned char file[512];
    wItem *currItem;

    if (!window_item("selected"))
        return 1;

    if (in_window("main"))
        return 1;
    if (in_window("video"))
        return 1;
    if (in_window("playbar"))
        return 1;

    mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin]    image selected: %s\n", in);

    currItem       = &skin->menuSelected;
    currItem->type = itBase;

    av_strlcpy(file, path, sizeof(file));
    av_strlcat(file, in, sizeof(file));

    if (skinImageRead(file, &currItem->Bitmap) != 0)
        return 1;

    currItem->width  = currItem->Bitmap.Width;
    currItem->height = currItem->Bitmap.Height;

    mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin]     bitmap: %dx%d\n", currItem->width, currItem->height);

    return 0;
}
/**
 * @brief Parse a @a dlabel definition.
 *
 *        Syntax: dlabel=x,y,width,align,fontfile,"text"
 *
 * @param in definition to be analyzed
 *
 * @return 0 (ok) or 1 (error)
 */
static int item_dlabel(char *in)
{
    int x, y, w, a, id;
    char fnt[256];
    char txt[256];
    wItem *item;

    if (!window_item("dlabel"))
        return 1;

    if (in_window("video"))
        return 1;
    if (in_window("menu"))
        return 1;

    x = cutItemToInt(in, ',', 0);
    y = cutItemToInt(in, ',', 1);
    w = cutItemToInt(in, ',', 2);
    a = cutItemToInt(in, ',', 3);
    cutItem(in, fnt, ',', 4);
    cutItem(in, txt, ',', 5);
    cutItem(txt, txt, '"', 1);

    mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin]    dlabel: \"%s\"\n", txt);
    mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin]     pos: %d,%d\n", x, y);
    mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin]     width: %d, align: %d\n", w, a);

    id = fntFindID(fnt);

    if (id < 0) {
        skin_error(MSGTR_SKIN_FONT_NonExistentFont, fnt);
        return 1;
    }

    mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin]     font: %s (#%d)\n", fnt, id);

    item = next_item();

    if (!item)
        return 1;

    item->type   = itDLabel;
    item->x      = x;
    item->y      = y;
    item->width  = w;
    item->height = -1;
    item->fontid = id;
    item->align  = a;
    item->label  = strdup(txt);

    if (!item->label) {
        skin_error(MSGTR_SKIN_NotEnoughMemory);
        return 1;
    }

    return 0;
}
/**
 * @brief Parse a @a menu definition.
 *
 *        Syntax: menu=x,y,width,height,message
 *
 * @param in definition to be analyzed
 *
 * @return 0 (ok) or 1 (error)
 */
static int item_menu(char *in)
{
    int x, y, w, h, message;
    char msg[32];
    wItem *item;

    if (!window_item("menu"))
        return 1;

    if (in_window("main"))
        return 1;
    if (in_window("video"))
        return 1;
    if (in_window("playbar"))
        return 1;

    x = cutItemToInt(in, ',', 0);
    y = cutItemToInt(in, ',', 1);
    w = cutItemToInt(in, ',', 2);
    h = cutItemToInt(in, ',', 3);
    cutItem(in, msg, ',', 4);

    message = appFindMessage(msg);

    if (message == -1) {
        skin_error(MSGTR_SKIN_UnknownMessage, msg);
        return 1;
    }

    item = next_item();

    if (!item)
        return 1;

    item->type    = itMenu;
    item->x       = x;
    item->y       = y;
    item->width   = w;
    item->height  = h;
    item->message = message;

    mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin]    item #%d: %d,%d %dx%d\n", *currWinItemIdx, x, y, w, h);
    mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin]     message: %s (#%d)\n", msg, message);

    item->Bitmap.Image = NULL;

    return 0;
}
예제 #5
0
int itm_find(WINDOW *w, int x, int y)
{
	if (in_window(w, x, y) == TRUE)
		return (((ITM_WINDOW *) w)->itm_func->itm_find) (w, x, y);
	else
		return -1;
}
예제 #6
0
파일: conio2.cpp 프로젝트: Aterwik111/PP
int kbhit(void)
{
	HANDLE con;
	DWORD nevents = 0;
	INPUT_RECORD buf;
	init_ti();
	if (nkeybuf) return 1;
	if (keystate) return 1;
	con = GetStdHandle(STD_INPUT_HANDLE);
	while (1)
	{
		GetNumberOfConsoleInputEvents(con, &nevents);
		if (nevents == 0) return 0;
		PeekConsoleInput(con, &buf, 1, &nevents);
		if (buf.EventType == KEY_EVENT && buf.Event.KeyEvent.bKeyDown)
			return 1;
		ReadConsoleInput(con, &buf, 1, &nevents);
		if (buf.EventType == WINDOW_BUFFER_SIZE_EVENT)
		{
			ti.screenwidth = buf.Event.WindowBufferSizeEvent.dwSize.X;
			ti.screenheight = buf.Event.WindowBufferSizeEvent.dwSize.Y;
			if (ti.winright>ti.screenwidth) ti.winright = ti.screenwidth;
			if (ti.winbottom>ti.screenheight) ti.winbottom = ti.screenheight;
			if (ti.winleft>ti.winright) ti.winleft = ti.winright;
			if (ti.wintop>ti.winbottom) ti.wintop = ti.winbottom;
			if (!in_window(ti.winleft + ti.curx - 1, ti.wintop + ti.cury - 1))
				gotoxy(1, 1);
		}
	}
}
예제 #7
0
파일: adaptknn.c 프로젝트: barak/lush
void 
learn_lvq3(struct codebook *cbdata, struct codebook *cbref, 
	   int nbit, flt a0, flt win)
{
  int i,j,nn1,nn2,c;
  flt alph = Fzero;
  
  for (i = 0; i < nbit; i++) {
    CHECK_MACHINE("on");
    for (j = 0; j < cbdata->ncode; j++)
      {
	c = cbdata->code[j].label;
	one_nn_and_a_half(cbdata->code[j].word,cbref,c,&nn1,&nn2);
	if (c!=cbref->code[nn1].label)
	  {
	    if (nn2<0)
	      error(NIL,"Class not represented in the references",
		    NEW_NUMBER(c));
	    if (in_window(&(cbref->code[nn1]), &(cbref->code[nn2]),
			  &(cbdata->code[j]), cbdata->ndim,
			  win ) )
	      {
		alph=alpha(a0,i,nbit);
		adapt(&(cbdata->code[j]),&(cbref->code[nn1]),alph,cbdata->ndim);
		adapt(&(cbdata->code[j]),&(cbref->code[nn2]),-alph,cbdata->ndim);
	      }
	  }
      }
  }
}
예제 #8
0
파일: adaptknn.c 프로젝트: barak/lush
void 
learn_lvq2(struct codebook *cbdata, struct codebook *cbref, 
	   int nbit, flt a0, flt win)
{
  int i,j,nn1,nn2;
  flt alph = Fzero;
  
  for (i = 0; i < nbit; i++) {
    CHECK_MACHINE("on");
    for (j = 0; j < cbdata->ncode; j++)
      {
	two_nn(cbdata->code[j].word,cbref,&nn1,&nn2);
	if (cbdata->code[j].label != cbref->code[nn1].label)
	  {
	    if (cbdata->code[j].label == cbref->code[nn2].label)
	      if (in_window(&(cbref->code[nn1]), &(cbref->code[nn2]),
			    &(cbdata->code[j]), cbdata->ndim,
			    win ) )
		{
		  alph=alpha(a0,i,nbit);
		  adapt(&(cbdata->code[j]),&(cbref->code[nn1]),alph,cbdata->ndim);
		  adapt(&(cbdata->code[j]),&(cbref->code[nn2]),-alph,cbdata->ndim);
		}
	  }
      }
  }
}
예제 #9
0
void flowcontrol_deliver_from_uart(border_packet_t *packet, int len)
{
    if (packet->type == BORDER_PACKET_ACK_TYPE) {
        if (in_window(packet->seq_num, slwin_stat.last_ack + 1, slwin_stat.last_frame)) {
            if (synack_seqnum == packet->seq_num) {
                synack_seqnum = -1;
                sem_post(&connection_established);
            }

            do {
                struct send_slot *slot;
                slot = &(slwin_stat.send_win[++slwin_stat.last_ack % BORDER_SWS]);
                vtimer_remove(&slot->timeout);
                memset(&slot->frame, 0, BORDER_BUFFER_SIZE);
                sem_post(&slwin_stat.send_win_not_full);
            }
            while (slwin_stat.last_ack != packet->seq_num);
        }
    }
    else {
        struct recv_slot *slot;

        slot = &(slwin_stat.recv_win[packet->seq_num % BORDER_RWS]);

        if (!in_window(packet->seq_num,
                       slwin_stat.next_exp,
                       slwin_stat.next_exp + BORDER_RWS - 1)) {
            return;
        }

        memcpy(slot->frame, (uint8_t *)packet, len);
        slot->received = 1;

        if (packet->seq_num == slwin_stat.next_exp) {
            while (slot->received) {
                demultiplex((border_packet_t *)slot->frame);
                memset(&slot->frame, 0, BORDER_BUFFER_SIZE);
                slot->received = 0;
                slot = &slwin_stat.recv_win[++(slwin_stat.next_exp) % BORDER_RWS];
            }
        }

        send_ack(slwin_stat.next_exp - 1);
    }
}
/**
 * @brief Parse a @a background definition.
 *
 *        Syntax: background=R,G,B
 *
 * @param in definition to be analyzed
 *
 * @return 0 (ok) or 1 (error)
 */
static int item_background(char *in)
{
    if (!window_item("background"))
        return 1;

    if (in_window("main"))
        return 1;
    if (in_window("playbar"))
        return 1;
    if (in_window("menu"))
        return 1;

    currWin->R = cutItemToInt(in, ',', 0);
    currWin->G = cutItemToInt(in, ',', 1);
    currWin->B = cutItemToInt(in, ',', 2);

    mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin]    background color: #%02x%02x%02x\n", currWin->R, currWin->G, currWin->B);

    return 0;
}
예제 #11
0
파일: conio2.cpp 프로젝트: Aterwik111/PP
void gotoxy(int __x, int __y)
{
	COORD c;
	init_ti();
	if (!in_window(ti.winleft + __x - 1, ti.wintop + __y - 1)) return;
	ti.curx = __x;
	ti.cury = __y;
	c.X = ti.winleft + ti.curx - 2;
	c.Y = ti.wintop + ti.cury - 2;
	SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), c);
}
예제 #12
0
파일: draw.cpp 프로젝트: EricWF/chips
 void draw_entities(sf::RenderWindow & win, position tl_pos, level const & lvl)
 {
     auto should_draw_pred = 
     [&](entity const & e)
     { return in_window(tl_pos, e); };
     
     for (auto & e : Predicate(should_draw_pred).filter(lvl.entity_list))
     {
         if (e.has<draw_list>()) {
             for (std::pair<tile_id, position> const & drawp : *e.get<draw_list>()) 
             {
                 if (not in_window(tl_pos, drawp.second)) continue;
                 draw_tile_at(
                     win, drawp.first
                   , position_in_window(tl_pos, drawp.second)
                 );
             }
         } else {
             draw_entity_at(win, e, position_in_window(tl_pos, e));
         }
     }
 }
예제 #13
0
파일: conio2.cpp 프로젝트: Aterwik111/PP
static void putchxyattr(int x, int y, int ch, int attr)
{
	CHAR_INFO buffer;
	SMALL_RECT r;
	COORD c = { 0,0 }, s = { 1,1 };
	if (!in_window(x, y)) return;
	r.Left = x - 1;
	r.Top = y - 1;
	r.Right = x - 1;
	r.Bottom = y - 1;
	buffer.Char.AsciiChar = ch;
	buffer.Attributes = attr;
	WriteConsoleOutputA(GetStdHandle(STD_OUTPUT_HANDLE), &buffer, s, c, &r);
}
/**
 * @brief Parse a @a font definition.
 *
 *        Syntax: font=fontfile
 *
 * @param in definition to be analyzed
 *
 * @return 0 (ok) or 1 (error)
 */
static int item_font(char *in)
{
    char fnt[256];

    if (!window_item("font"))
        return 1;

    if (in_window("video"))
        return 1;
    if (in_window("menu"))
        return 1;

    cutItem(in, fnt, ',', 0);   // Note: This seems needless but isn't for compatibility
                                // reasons with a meanwhile depreciated second parameter.
    switch (fntRead(path, fnt)) {
    case -1:
        skin_error(MSGTR_SKIN_NotEnoughMemory);
        return 1;

    case -2:
        skin_error(MSGTR_SKIN_FONT_TooManyFontsDeclared);
        return 1;

    case -3:
        skin_error(MSGTR_SKIN_FONT_FontFileNotFound);
        return 1;

    case -4:
        skin_error(MSGTR_SKIN_FONT_FontImageNotFound);
        return 1;
    }

    mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin]    font: %s (#%d)\n", fnt, fntFindID(fnt));

    return 0;
}
예제 #15
0
void wd_hndlbutton(WINDOW *w, int x, int y, int n, int bstate,
				   int kstate)
{
	int item, m_state;

	if (selection.w != w)
		desel_old();

	m_state = xe_button_state();
	item = itm_find(w, x, y);

	if (item >= 0)
	{
		if (n == 2)
		{
			itm_select(w, item, 0, TRUE);
			itm_set_menu(w);

			wait_button();

			if (itm_open(w, item, kstate) == TRUE)
				itm_select(w, item, 2, TRUE);
		}
		else
		{
			if ((m_state == 0) || (itm_state(w, item) == FALSE))
			{
				itm_select(w, item, (kstate & 3) ? 1 : 0, TRUE);
				itm_set_menu(w);
			}

			if ((m_state != 0) && (itm_state(w, item) == TRUE))
				itm_move(w, item, x, y);
		}

		itm_set_menu(selection.w);
	}
	else if (in_window(w, x, y) == TRUE)
	{
		if (((m_state == 0) || ((kstate & 3) == 0)) && (selection.w == w))
			itm_select(w, -1, 0, TRUE);
		if (m_state)
			itm_rselect(w, x, y);
		itm_set_menu(w);
	}
}
예제 #16
0
파일: draw.cpp 프로젝트: EricWF/chips
 bool in_window(position top_left, entity const & e)
 {
     if (not e) return false;
     return in_window(top_left, e.get<position>());
 }
예제 #17
0
파일: conio2.cpp 프로젝트: Aterwik111/PP
int getkbm(void)
{
	HANDLE con;
	DWORD nevents = 0;
	INPUT_RECORD buf;
	init_ti();
	if (nkeybuf)
	{
		return keybuf[--nkeybuf];
	}
	if (keystate) keystate = 0;
	con = GetStdHandle(STD_INPUT_HANDLE);
	while (1)
	{
		ReadConsoleInputA(con, &buf, 1, &nevents);
		if (buf.EventType == KEY_EVENT && buf.Event.KeyEvent.bKeyDown)
		{
			_controlkeystate = buf.Event.KeyEvent.dwControlKeyState;
			if (buf.Event.KeyEvent.uChar.AsciiChar == 0)
				return KEY_SPECIAL + buf.Event.KeyEvent.wVirtualScanCode;
			return buf.Event.KeyEvent.uChar.AsciiChar & 0xFF;
		}
		else if (buf.EventType == WINDOW_BUFFER_SIZE_EVENT)
		{
			ti.screenwidth = buf.Event.WindowBufferSizeEvent.dwSize.X;
			ti.screenheight = buf.Event.WindowBufferSizeEvent.dwSize.Y;
			if (ti.winright>ti.screenwidth) ti.winright = ti.screenwidth;
			if (ti.winbottom>ti.screenheight) ti.winbottom = ti.screenheight;
			if (ti.winleft>ti.winright) ti.winleft = ti.winright;
			if (ti.wintop>ti.winbottom) ti.wintop = ti.winbottom;
			if (!in_window(ti.winleft + ti.curx - 1, ti.wintop + ti.cury - 1))
				gotoxy(1, 1);
			return WINDOW_RESIZE;
		}
		else if (buf.EventType == MOUSE_EVENT)
		{
			switch (buf.Event.MouseEvent.dwEventFlags)
			{
			case 0:
				if (buf.Event.MouseEvent.dwButtonState != 0)
				{
					_mousebuttons = buf.Event.MouseEvent.dwButtonState;
					_mousex = buf.Event.MouseEvent.dwMousePosition.X + 1;
					_mousey = buf.Event.MouseEvent.dwMousePosition.Y + 1;
					return MOUSE_CLICK;
				}
				break;
			case DOUBLE_CLICK:
				_mousebuttons = buf.Event.MouseEvent.dwButtonState;
				_mousex = buf.Event.MouseEvent.dwMousePosition.X + 1;
				_mousey = buf.Event.MouseEvent.dwMousePosition.Y + 1;
				return MOUSE_DBLCLICK;
			case MOUSE_WHEELED:
				_mousex = buf.Event.MouseEvent.dwMousePosition.X + 1;
				_mousey = buf.Event.MouseEvent.dwMousePosition.Y + 1;
				if ((int)buf.Event.MouseEvent.dwButtonState>0)
					return MOUSE_WHEELUP;
				return MOUSE_WHEELDOWN;
			default:
				break;
			}
		}
	}
}
/**
 * @brief Parse a @a potmeter definition.
 *
 *        Syntax: potmeter=phases,numphases,default,x,y,width,height,message
 *
 * @param in definition to be analyzed
 *
 * @return 0 (ok) or 1 (error)
 */
static int item_potmeter(char *in)
{
    unsigned char phfname[256];
    unsigned char buf[512];
    int ph, d, x, y, w, h, message;
    wItem *item;

    if (!window_item("potmeter"))
        return 1;

    if (in_window("video"))
        return 1;
    if (in_window("menu"))
        return 1;

    cutItem(in, phfname, ',', 0);
    ph = cutItemToInt(in, ',', 1);
    d  = cutItemToInt(in, ',', 2);
    x  = cutItemToInt(in, ',', 3);
    y  = cutItemToInt(in, ',', 4);
    w  = cutItemToInt(in, ',', 5);
    h  = cutItemToInt(in, ',', 6);
    cutItem(in, buf, ',', 7);

    message = appFindMessage(buf);

    if (message == -1) {
        skin_error(MSGTR_SKIN_UnknownMessage, buf);
        return 1;
    }

    mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin]    potmeter image: %s %d,%d %dx%d\n", phfname, x, y, w, h);
    mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin]     numphases: %d, default: %d%%\n", ph, d);
    mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin]     message: %s (#%d)\n", buf, message);

    item = next_item();

    if (!item)
        return 1;

    item->type      = itPotmeter;
    item->x         = x;
    item->y         = y;
    item->width     = w;
    item->height    = h;
    item->numphases = ph;
    item->value     = (float)d;
    item->message   = message;

    item->Bitmap.Image = NULL;

    if (strcmp(phfname, "NULL") != 0) {
        av_strlcpy(buf, path, sizeof(buf));
        av_strlcat(buf, phfname, sizeof(buf));

        if (skinImageRead(buf, &item->Bitmap) != 0)
            return 1;

        mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin]     (bitmap: %lux%lu)\n", item->Bitmap.Width, item->Bitmap.Height);
    }

    return 0;
}
/**
 * @brief Parse a @a button definition.
 *
 *        Syntax: button=image,x,y,width,height,message
 *
 * @param in definition to be analyzed
 *
 * @return 0 (ok) or 1 (error)
 */
static int item_button(char *in)
{
    unsigned char fname[256];
    unsigned char file[512];
    int x, y, w, h, message;
    char msg[32];
    wItem *item;

    if (!window_item("button"))
        return 1;

    if (in_window("video"))
        return 1;
    if (in_window("menu"))
        return 1;

    cutItem(in, fname, ',', 0);
    x = cutItemToInt(in, ',', 1);
    y = cutItemToInt(in, ',', 2);
    w = cutItemToInt(in, ',', 3);
    h = cutItemToInt(in, ',', 4);
    cutItem(in, msg, ',', 5);

    message = appFindMessage(msg);

    if (message == -1) {
        skin_error(MSGTR_SKIN_UnknownMessage, msg);
        return 1;
    }

    mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin]    button image: %s %d,%d\n", fname, x, y);
    mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin]     message: %s (#%d)\n", msg, message);
    mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin]     size: %dx%d\n", w, h);

    item = next_item();

    if (!item)
        return 1;

    item->type    = itButton;
    item->x       = x;
    item->y       = y;
    item->width   = w;
    item->height  = h;
    item->message = message;
    item->pressed = btnReleased;

    if (item->message == evPauseSwitchToPlay)
        item->pressed = btnDisabled;

    item->Bitmap.Image = NULL;

    if (strcmp(fname, "NULL") != 0) {
        av_strlcpy(file, path, sizeof(file));
        av_strlcat(file, fname, sizeof(file));

        if (skinImageRead(file, &item->Bitmap) != 0)
            return 1;

        mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin]     (bitmap: %lux%lu)\n", item->Bitmap.Width, item->Bitmap.Height);
    }

    return 0;
}