示例#1
0
文件: skin.c 项目: xaradevil/tcvp
extern int
tcvp_on_top(xtk_widget_t *w, void *p)
{
    widget_data_t *wd = xtk_widget_get_data(w);
    char *d = wd->action_data;
    skin_t *s = wd->skin;

    if(!d || strcasecmp(d, "toggle") == 0) {
        if(s->state & ST_ON_TOP) {
            xtk_window_set_always_on_top(s->window, 0);
            s->state &= ~ST_ON_TOP;
        } else {
            xtk_window_set_always_on_top(s->window, 1);
            s->state |= ST_ON_TOP;
        }
    } else if(strcasecmp(d, "set") == 0) {
        xtk_window_set_always_on_top(s->window, 1);
        s->state |= ST_ON_TOP;
    } else if(strcasecmp(d, "unset") == 0) {
        xtk_window_set_always_on_top(s->window, 0);
        s->state &= ~ST_ON_TOP;
    }

    if(s->state & ST_ON_TOP) {
        change_text("on_top", "set");
    } else {
        change_text("on_top", "unset");
    }

    return 0;
}
示例#2
0
文件: skin.c 项目: xaradevil/tcvp
extern int
tcvp_sticky(xtk_widget_t *w, void *p)
{
    widget_data_t *wd = xtk_widget_get_data(w);
    char *d = wd->action_data;
    skin_t *s = wd->skin;

    if(!d || strcasecmp(d, "toggle") == 0) {
        if(s->state & ST_STICKY) {
            xtk_window_set_sticky(s->window, 0);
            s->state &= ~ST_STICKY;
        } else {
            xtk_window_set_sticky(s->window, 1);
            s->state |= ST_STICKY;
        }
    } else if(strcasecmp(d, "set") == 0) {
        xtk_window_set_sticky(s->window, 1);
        s->state |= ST_STICKY;
    } else if(strcasecmp(d, "unset") == 0) {
        xtk_window_set_sticky(s->window, 0);
        s->state &= ~ST_STICKY;
    }

    if(s->state & ST_STICKY) {
        change_text("sticky", "set");
    } else {
        change_text("sticky", "unset");
    }

    return 0;
}
void switch_mode()
{
	if (mode)
	{
		change_text(BASE, find_id(BASE, "Switch mode") + 1, "  Current mode: 1");
		mode = 0;
	}
	else
	{
		change_text(BASE, find_id(BASE, "Switch mode") + 1, "  Current mode: 2");
		mode = 1;
	}
	show_base();
}
示例#4
0
文件: skin.c 项目: xaradevil/tcvp
extern int
on_top_cb(xtk_widget_t *w, int i)
{
    widget_data_t *wd = xtk_widget_get_data(w);
    skin_t *s = wd->skin;

    if(i == 0) {
        s->state &= ~ST_ON_TOP;
        change_text("on_top", "unset");
    } else {
        s->state |= ST_ON_TOP;
        change_text("on_top", "set");
    }

    return 0;
}
BOOL CMFCApplication1Dlg::PreTranslateMessage(MSG* pMsg) {
	CWnd* temp_time = GetDlgItem(IDC_TIMER);
	CString t_time;

	switch (pMsg->message)
	{
		

		case WM_TIMER: //ako traje igra, svakih 0.1 sekundi provjerava da li je "duration" manji od 0, ako je poziva se "game over", ako nije da se "duration" smanji za 0.1
			if (game == true) {
				duration -= 0.1;
				if (duration < 0)
					game_over();
				t_time.Format(_T("%.1f"), duration);
				temp_time->SetWindowText(LPCTSTR(t_time));
				return false;
			}

		case WM_KEYUP: //prepoznavanje stisnute tipke
			if (pMsg->wParam == VK_RETURN) { // poèetak ili reset igre
				new_game();
				CWnd *_help = GetDlgItem(IDC_INST);
				_help->SetWindowText(_T(""));
			}
			else if (pMsg->wParam == VK_ESCAPE) { // izlazak iz igre
				EndDialog(IDCANCEL);

			}
			else if (GetAsyncKeyState(current_word[0]) && game == true) { //provjera da li je pritisnuta tipka jednaka traženom slovu

				if (current_word.Mid(1).IsEmpty()) { //ako nema više slova poveæava se "score"  i postavlja se nova rijeè

					set_score();
					new_word();
				}

				else { //za svako pogoðeno slovo, to slovo se mièe iz prikaza rijeèi i svira zvuk za pogoðeno slovo

					sound_path.LoadString(IDS_S_WRITE);
					PlaySound(sound_path, GetModuleHandle(NULL), SND_ASYNC); //zvuk za dobro upisano slovo
					current_word = current_word.Mid(1); //mièe se prvi znak(slovo) iz rijeèi
					change_text(); //postavlja se tekst bez prvog znaka
				}
			}
			else if (GetAsyncKeyState('H') && game == false) //kada igra ne traje ako je "H" pritisnut prikazuju se instrukcije za igranje igre
			{
				CString res;
				CString res2;
				res.LoadString(IDS_M_HELP);
				res2.LoadString(IDS_M_HELP_T);
				MessageBox(res, res2);
			}
			else if (game == true) //ako igra traje i nije pogoðeno slovo, poziva se "game over"
				game_over();

			return true;

	}
		return false;
}
void CMFCApplication1Dlg::new_word() { //provjera na koliko je bodova igraè i po tome se odreðuje velièina rijeèi koje æe upisivati
	std::vector<std::string>::iterator it;


	random_shuffle(list_words.begin(), list_words.end()); 
	it = find_if(list_words.begin(), list_words.end(), isLength(score));
	std::string t = *it; 
	current_word = t.c_str();

	change_text(); //izmjena text-a za upis
	timer(); //reset timer-a

}
示例#7
0
文件: initx.c 项目: fricas/fricas
int
init_top_window(char *name)
{
    HyperDocPage *page;
    XSetWindowAttributes wa;    /* The X attributes structure */
    HDWindow *old_win = gWindow;

    gWindow = alloc_hd_window();

    if (name == NULL) {
        /** Then allocate an empty page, and assign it to gWindow->page */
        page = alloc_page((char *) NULL);
    }
    else {
        /* Try to find the page in the page hash table */
        page = (HyperDocPage *) hash_find(gWindow->fPageHashTable, name);
        if (page == NULL) {
            fprintf(stderr, "(HyperDoc)  Couldn\'t find page %s in page hash table \n",
                    name);
            if (gParentWindow == NULL)
                /* Gaak, This is a start up error */
                exit(-1);
            else {
                gWindow = old_win;
                return -1;
            }
        }
    }

    /* First allocate memory for the new window structure   */
    gWindow->page = page;

    if (old_win == NULL)
        open_window(0);
    else
        open_window(old_win->fMainWindow);

    get_GCs(gWindow);
    XMapWindow(gXDisplay, gWindow->fMainWindow);
    hash_insert(&gSessionHashTable, (char *)gWindow,(char *) &gWindow->fMainWindow);

    change_text(gRmColor, gRmFont);
    wa.background_pixel = gBackgroundColor;
    XChangeWindowAttributes(gXDisplay, gWindow->fMainWindow, CWBackPixel, &wa);
    XChangeWindowAttributes(gXDisplay, gWindow->fScrollWindow, CWBackPixel,&wa);
    return 1;
}
示例#8
0
		view( QWidget * top = 0 ): m_top(top)
		{

		
			m_numpad = new QWidget(m_top);
			m_operators = new QWidget(m_top) ;
			
			// output
			m_output = new QLineEdit("0",m_top);
			
			m_output->setReadOnly(true);
			m_output->setStyleSheet("QLineEdit { background-color: #8B8B7A; border-style: outset; border-width: 2px; border-color: #8B8B7A ; color: white ; }");
			
			// result output
			m_result = new QLineEdit("0",m_top);
			m_result->setReadOnly(true);
			m_result->setStyleSheet("QLineEdit { background-color: #8B8B7A; border-style: outset; border-width: 2px; border-color: #8B8B7A ; color: white ; }");
		
		
			// numpad grid
			m_grid_numpad = new QGridLayout(m_numpad) ;
			
			
			
			// initialize buttons
			for( int i=0 ; i<10 ; ++i )
			{
				m_figures.insert(i,new QPushButton(QString::number(i),m_numpad) );
				m_figures.at(i)->setStyleSheet(" QPushButton { background-color:  #333333 ; color: white ; }");
			}
			
			m_comma = new QPushButton(",",m_numpad);
			m_comma->setStyleSheet("QPushButton { background-color:  #333333 ; color: white ; }");

			
			int j = 9 ;
			while ( j>=1 )
			{
				for ( int i = 0 ; i < 3 ; ++i )
				{	
					for ( int k = 2 ; k >=0 ; --k )
					{
						m_grid_numpad->addWidget(m_figures[j],i,k);
						--j;
					}
				}
			}
			
			
			m_grid_numpad->addWidget(m_figures[0],3,0,1,2);
			m_grid_numpad->addWidget(m_comma,3,2,1,1);
			m_grid_numpad->setMargin(0); 
			m_grid_numpad->setVerticalSpacing(0) ;
			m_grid_numpad->setHorizontalSpacing(0) ;
			
			

			m_addition = new QPushButton("+",m_operators);
			m_substraction = new QPushButton("-",m_operators);
			m_multiplication = new QPushButton("*",m_operators);
			m_division = new QPushButton("/",m_operators);
			m_r_bracket = new QPushButton("(",m_operators);
			m_l_bracket = new QPushButton(")",m_operators);
			m_square = new QPushButton("^2",m_operators);
			m_equal = new QPushButton("=",m_operators);
			
			
			//style 
			m_addition->setStyleSheet("QPushButton { background-color: #333333 ; color: white ; }");
			m_substraction->setStyleSheet("QPushButton { background-color: #333333 ; color: white ; }");
			m_multiplication->setStyleSheet("QPushButton { background-color: #333333 ; color: white ; }");
			m_division->setStyleSheet("QPushButton { background-color: #333333 ; color: white ; }");
			m_r_bracket->setStyleSheet("QPushButton { background-color: #333333 ; color: white ; }");
			m_l_bracket->setStyleSheet("QPushButton { background-color: #333333 ; color: white ; }");
			m_square->setStyleSheet("QPushButton { background-color: #333333 ; color: white ; }");
			m_equal->setStyleSheet("QPushButton { background-color: #333333 ; color: white ; }");
			
			
			m_grid_operators = new QGridLayout(m_operators) ;
			m_grid_operators->setMargin(0); 
			m_grid_operators->setVerticalSpacing(0) ;
			m_grid_operators->setHorizontalSpacing(0) ;
			
			
			m_grid_operators->addWidget(m_addition,0,0);
			m_grid_operators->addWidget(m_substraction,0,1);
			m_grid_operators->addWidget(m_multiplication,1,0);
			m_grid_operators->addWidget(m_division,1,1);
			m_grid_operators->addWidget(m_r_bracket,2,0);
			m_grid_operators->addWidget(m_l_bracket,2,1);
			m_grid_operators->addWidget(m_square,3,0);
			m_grid_operators->addWidget(m_equal,3,1);
			
	
			// main layout
			m_box = new QGridLayout(m_top);
		
			
			m_box->addWidget(m_output,1,1,1,3);
			m_box->addWidget(m_result,2,2,1,2);
			m_box->addWidget(m_numpad,4,1,1,1);
			m_box->addWidget(m_operators,4,3,1,1);
			m_box->setRowStretch(0,1);
			m_box->setRowStretch(3,1);
			m_box->setRowStretch(5,1);
			
			m_box->setColumnStretch(0,1);
			m_box->setColumnStretch(0,1);
			m_box->setColumnStretch(2,1);
			
			m_box->setColumnStretch(4,1);
			
			QObject::connect(m_addition,SIGNAL(clicked()),&m_controller,SLOT(add()) );
			QObject::connect(m_substraction,SIGNAL(clicked()),&m_controller,SLOT(add()) );
			QObject::connect(m_multiplication,SIGNAL(clicked()),&m_controller,SLOT(add()) );
			QObject::connect(m_division,SIGNAL(clicked()),&m_controller,SLOT(add()) );
			QObject::connect(m_r_bracket,SIGNAL(clicked()),&m_controller,SLOT(add()) );
			QObject::connect(m_l_bracket,SIGNAL(clicked()),&m_controller,SLOT(add()) );
			QObject::connect(m_square,SIGNAL(clicked()),&m_controller,SLOT(add()) );
			QObject::connect(m_equal,SIGNAL(clicked()),&m_controller,SLOT(add()) );
			QObject::connect(m_comma,SIGNAL(clicked()),&m_controller,SLOT(add()) );
			

			for( int i=0 ; i<10 ; ++i )
			{
				QObject::connect(m_figures[i],SIGNAL(clicked()),&m_controller,SLOT(add()));
			}
			
			QObject::connect(&m_controller,SIGNAL(result(QString)),m_result,SLOT(setText(QString)));
			QObject::connect(&m_controller,SIGNAL(change_text(QString)),m_output,SLOT(setText(QString)));
			top->show();
		
		}
示例#9
0
int main(void)
{
	char key;				//current key press
	int i = 0, j = 1;		//color tracking variable and quote tracking variable
	int x = 300, y = 200;	//starting coordinates
	color_t c;				//current color
	
	//set up the screen
	init_graphics();	
	clear_screen();
	set_colors();	
	draw_mario(x, y);
	draw_header();
	draw_footer();
	
	//begin color with red
	c = colors[i++];
	
	do
	{
		key = getkey();
		if(key == 'a')
		{
			clear_mario(x, y);
			x -= 20;							//move mario left
			draw_mario(x, y);
		}
		else if(key == 's')
		{
			clear_mario(x, y);
			y += 30;							//move mario down
			draw_mario(x, y);
		}
		else if(key == 'd')
		{
			clear_mario(x, y);
			x += 20;							//move mario right
			draw_mario(x, y);
		}
		else if(key == 'w')
		{
			clear_mario(x, y);
			y -= 30;							//move mario up
			draw_mario(x, y);
		}
		else if(key == 'r')
		{
			draw_rect(x+52, y, 20, 30, c);		//draw a rectangle
		}
		else if(key == 'f')
		{
			fill_rect(x+52, y, 20, 30, c);		//draw a filled rectangle
		}
		else if(key == '/')
		{
			c = colors[i++];					//cycle colors
			if(i == 8)
				i = 0;
		}
		else if(key == ' ')
		{
			//reset counter if needed
			if(j == 8)
				j = 0;
			change_text(j++, c);				//change the quote in the header
		}
		sleep_ms(20);
	} while(key != 'q');
	
	exit_graphics();
	
	return 0;
}