本文整理汇总了C++中Menu::SetWindow方法的典型用法代码示例。如果您正苦于以下问题:C++ Menu::SetWindow方法的具体用法?C++ Menu::SetWindow怎么用?C++ Menu::SetWindow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Menu
的用法示例。
在下文中一共展示了Menu::SetWindow方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv)
{
InitAllegro();
ALLEGRO_KEYBOARD_STATE klawiatura;
ALLEGRO_MOUSE_STATE mysz;
ALLEGRO_EVENT_QUEUE* event_queue = al_create_event_queue();
ALLEGRO_EVENT_QUEUE* key_queue = al_create_event_queue();
ALLEGRO_DISPLAY* okno = al_create_display(WINDOW_WIDTH, WINDOW_HEIGHT);
ALLEGRO_FONT* defaultFont = al_create_builtin_font();
ALLEGRO_TIMER* timer = al_create_timer(1.0 / 60.0);
al_register_event_source(key_queue, al_get_display_event_source(okno));
al_register_event_source(event_queue, al_get_display_event_source(okno));
al_register_event_source(key_queue, al_get_keyboard_event_source());
al_register_event_source(event_queue, al_get_timer_event_source(timer));
al_set_window_title(okno, "Fraktale");
al_set_target_bitmap(al_get_backbuffer(okno));
Menu* menu = new Menu(WINDOW_WIDTH, WINDOW_HEIGHT);
Mandelbrot* mandelbrot = new Mandelbrot(WINDOW_WIDTH, WINDOW_HEIGHT, defaultFont);
Julia* julia = new Julia(WINDOW_WIDTH, WINDOW_HEIGHT, defaultFont);
Window* window = new Window(menu, mandelbrot, julia);
menu->SetWindow(window);
mandelbrot->SetWindow(window);
julia->SetWindow(window);
const ALLEGRO_COLOR backgroundColor = al_map_rgb(255, 255, 255);
const ALLEGRO_COLOR frameColor = al_map_rgb(255, 255, 255);
const int frameThickness = 2;
ALLEGRO_USTR* str = al_ustr_new("");
int pos = (int)al_ustr_size(str);
ALLEGRO_EVENT ev;
double blokadaKlikniecia = al_get_time();
int poczX = -1, poczY = -1, poprzedniStan = window->stanOkna;
bool petla = true, klikniecieMyszy = false, klawiszWcisniety = false, wpisywanieIteracji = false;
double screenRatio = static_cast<double>(WINDOW_HEIGHT) / static_cast<double>(WINDOW_WIDTH);
while (petla)
{
if (poprzedniStan != window->stanOkna)
{
blokadaKlikniecia = al_get_time();
}
poprzedniStan = window->stanOkna;
al_get_next_event(event_queue, &ev);
al_get_mouse_state(&mysz);
int mx = mysz.x;
int my = mysz.y;
bool koniecKlikniecia = false;
if (mysz.buttons & 1 && klikniecieMyszy == false && al_get_time() > blokadaKlikniecia + 0.3)
{
klikniecieMyszy = true;
if (window->CzyFraktal())
{
poczX = mx;
poczY = my;
}
}
else if (!(mysz.buttons & 1) && klikniecieMyszy == true && al_get_time() > blokadaKlikniecia + 0.3)
{
klikniecieMyszy = false;
int pp = window->stanOkna;
int respond = window->Click(mx, my);
if (respond == Responds_t::RESPOND_CLOSE_WINDOW)
petla = false;
if (window->CzyFraktal() && (pp == WINDOWSTATE_MANDELBROT || pp == WINDOWSTATE_JULIA))
{
koniecKlikniecia = true;
}
if (pp == WINDOWSTATE_MENU && window->CzyFraktal())
{
window->ZaladujFraktal();
}
}
if (koniecKlikniecia)
{
if (window->CzyFraktal())
{
Fraktal* fraktal = window->AktualnyFraktal();
fraktal->Powieksz(poczX, mx, poczY, SkalujY(poczY, screenRatio, poczX, mx));
}
poczX = -1, poczY = -1;
//.........这里部分代码省略.........