/* ** DBus method call: "RoomChangeTeam" */ gboolean on_handle_room_change_team(Warfacebot *object, GDBusMethodInvocation *invocation) { cmd_switch(); warfacebot_complete_room_change_team(object, invocation); return TRUE; }
LRESULT CALLBACK App::subclass_wndproc_new(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){ //odnalezienie kontrolki Control* kontrolka = NULL; for(unsigned int i=0; i<Controls::geti()->controls.size(); i++){ if(Controls::geti()->controls.at(i)->handle == hwnd){ kontrolka = Controls::geti()->controls.at(i); break; } } if(kontrolka==NULL){ IO::geti()->error("Subclassing: Nie znaleziono kontrolki o podanym uchwycie"); return 0; } string nazwa = kontrolka->name; //globalne skróty klawiszowe if(message == WM_KEYDOWN){ if(wParam==VK_F1||wParam==VK_F2||wParam==VK_F3||wParam==VK_F5||wParam==VK_F6||wParam==VK_F7||wParam==VK_F8||wParam==VK_F9||wParam==VK_F10||wParam==VK_F11){ CallWindowProc(windowProc, hwnd, message, wParam, lParam); //przekazanie wy¿ej do mainwindow return 0; //przechwycenie } //wyjœcie z fullscreena if(wParam==VK_ESCAPE && Config::geti()->fullscreen_on){ CallWindowProc(windowProc, hwnd, message, wParam, lParam); //przekazanie wy¿ej do mainwindow return 0; //przechwycenie } //ctrl if(is_control_pressed()){ if(wParam=='S'||wParam=='F'||wParam=='N'||wParam=='B'||wParam==VK_ADD||wParam==VK_SUBTRACT||wParam==VK_LEFT||wParam==VK_RIGHT||wParam=='0'||wParam==VK_NUMPAD0||wParam==VK_OEM_3){ CallWindowProc(windowProc, hwnd, message, wParam, lParam); //przekazanie wy¿ej do mainwindow return 0; //przechwycenie } } } if(message == WM_SYSKEYDOWN){ if(wParam==VK_F10){ //zamiana WM_SYSKEYDOWN na WM_KEYDOWN subclass_wndproc_new(hwnd, WM_KEYDOWN, wParam, lParam); return 0; } } //globalne przechwycenie wygaszacza if(message == WM_SYSCOMMAND){ if(wParam == SC_SCREENSAVE){ CallWindowProc(windowProc, hwnd, message, wParam, lParam); //przekazanie wy¿ej do mainwindow return 0; //przechwycenie } } //nowe procedury kontrolek if(nazwa=="filename_edit"){ switch(message){ case WM_CHAR:{ if(wParam==VK_ESCAPE){ Controls::geti()->set_focus("editor"); return 0; }else if(wParam==VK_RETURN){ if(!Config::geti()->cmd_show){ cmd_switch(1); } Controls::geti()->set_focus("cmd"); Controls::geti()->select_all("cmd"); return 0; } }break; } } if(nazwa=="cmd"){ switch(message){ case WM_CHAR:{ if(wParam==VK_ESCAPE){ Controls::geti()->set_focus("editor"); return 0; }else if(wParam==VK_RETURN){ exec_cmd(); return 0; //przechwycenie } }break; case WM_KEYDOWN:{ if(wParam==VK_UP){ Controls::geti()->set_text("cmd", last_cmd); SendMessage(Controls::geti()->find("cmd"), EM_SETSEL, last_cmd.length(), last_cmd.length()); return 0; } if(wParam==VK_DOWN){ Controls::geti()->set_text("cmd", ""); return 0; } }break; } } if(nazwa=="editor"){ //edytor switch(message){ case WM_SYSKEYDOWN:{ if(wParam>='1' && wParam<='9'){ //zamiana WM_SYSKEYDOWN na WM_KEYDOWN subclass_wndproc_new(hwnd, WM_KEYDOWN, wParam, lParam); return 0; } }break; case WM_KEYDOWN:{ if(is_control_pressed()){ //ctrl if(wParam=='C'){ copy_text(); return 0; }else if(wParam=='A'){ select_all(); return 0; }else if(wParam=='Z'){ undo->revert(); return 0; }else if(wParam=='R'){ refresh_text(); return 0; }else if(wParam=='T'){ quick_replace(); return 0; }else if(wParam=='Q'){ usun_akordy(); return 0; }else if(wParam=='W'){ save_pattern(); return 0; }else if(wParam=='E'){ insert_pattern(); return 0; }else if(wParam=='D'){ dodaj_nawias(); return 0; }else if(wParam>='1' && wParam<='9'){ zapisz_tekst(wParam-'1'+1); return 0; } }else if(is_alt_pressed()){ //alt if(wParam>='1' && wParam<='9'){ wstaw_tekst(wParam-'1'+1); return 0; } } }break; case WM_CHAR:{ //dla ka¿dego znaku (bez controla) if(!is_control_pressed()){ undo->save(); } //undo->save(); if(wParam == ']'){ string add_text = "]"; SendMessage(Controls::geti()->find("editor"), EM_REPLACESEL, 0, (LPARAM)add_text.c_str()); //wstawienie znaku refresh_text(); //odœwie¿enie tekstu //zmiana koloru po nawiasie na kolor tekstu CHARFORMAT cf_text; cf_text.cbSize = sizeof(cf_text); SendMessage(Controls::geti()->find("editor"), EM_GETCHARFORMAT, SCF_DEFAULT, (LPARAM)&cf_text); //kolor tekstu + brak pogrubienia cf_text.dwMask = CFM_COLOR | CFM_BOLD; cf_text.crTextColor = RGB(Config::i()->color_text[0], Config::i()->color_text[1], Config::i()->color_text[2]); cf_text.dwEffects = 0; SendMessage(Controls::geti()->find("editor"), EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf_text); return 0; } }break; case WM_MOUSEWHEEL:{ int zdelta = GET_WHEEL_DELTA_WPARAM(wParam); if(LOWORD(wParam)==MK_CONTROL){ //z controlem //zmiana czcionki if(zdelta>=0){ change_font_size(+1); }else{ change_font_size(-1); } return 0; }else{ //scrollowanie edytora int scroll_step = Config::geti()->editor_fontsize + 2; if(zdelta>=0){ change_scroll(-scroll_step); }else{ change_scroll(+scroll_step); } return 0; } }break; } } if(nazwa=="find_edit"){ //szukany ci¹g znaków switch(message){ case WM_SETFOCUS:{ if(Controls::i()->get_text("find_edit")==Config::i()->find_edit_placeholder){ Controls::i()->set_text("find_edit", ""); } IO::geti()->echo("(Wpisz szukany ci¹g znaków, Enter - szukaj)"); }break; case WM_KILLFOCUS:{ if(Controls::i()->get_text("find_edit").length()==0){ Controls::i()->set_text("find_edit", Config::i()->find_edit_placeholder); } }break; case WM_CHAR:{ if(wParam==VK_RETURN){ znajdz(); return 0; } if(wParam==VK_TAB){ Controls::geti()->set_focus("replace_edit"); return 0; } }break; } } if(nazwa=="replace_edit"){ //tekst do zamiany switch(message){ case WM_SETFOCUS:{ if(Controls::i()->get_text("replace_edit")==Config::i()->replace_edit_placeholder){ Controls::i()->set_text("replace_edit", ""); } IO::geti()->echo("(Wpisz tekst do zamiany, Enter - zamieñ w zaznaczeniu lub ca³ym pliku)"); }break; case WM_KILLFOCUS:{ if(Controls::i()->get_text("replace_edit").length()==0){ Controls::i()->set_text("replace_edit", Config::i()->replace_edit_placeholder); } }break; case WM_CHAR:{ if(wParam==VK_RETURN){ zamien(); return 0; } if(wParam==VK_TAB){ Controls::geti()->set_focus("find_edit"); return 0; } }break; } } if(nazwa=="autoscroll_interval"){ //autoscroll_interval switch(message){ case WM_SETFOCUS:{ IO::geti()->echo("(Czas miêdzy kolejnymi przebiegami autoscrolla - wyra¿ony w milisekundach)"); }break; case WM_CHAR:{ if(wParam==VK_RETURN){ autoscroll_nowait(0); return 0; } }break; } } if(nazwa=="autoscroll_wait"){ //autoscroll_wait switch(message){ case WM_SETFOCUS:{ IO::geti()->echo("(Czas opóŸnienia przed autoscrollem - wyra¿ony w sekundach)"); }break; case WM_CHAR:{ if(wParam==VK_RETURN){ autoscroll_on(); return 0; } }break; } } return CallWindowProc(kontrolka->wndproc_old, hwnd, message, wParam, lParam); }
bool App::event_keydown(WPARAM wParam){ if(wParam==VK_ESCAPE){ if(Config::geti()->fullscreen_on){ //wyjœcie z fullscreena fullscreen_set(false); }else{ Controls::geti()->set_focus("editor"); } }else if(wParam==VK_F1){ set_scroll(0); }else if(wParam==VK_F2){ change_scroll(-35); }else if(wParam==VK_F3){ change_scroll(+35); }else if(wParam==VK_F5){ autoscroll_nowait(+Config::geti()->autoscroll_interval*0.25); }else if(wParam==VK_F6){ autoscroll_nowait(-Config::geti()->autoscroll_interval*0.2); }else if(wParam==VK_F7){ autoscroll_switch(); }else if(wParam==VK_F8){ if(Config::geti()->autoscroll){ autoscroll_off(); IO::geti()->echo("Autoscroll wy³¹czony"); }else{ autoscroll_nowait(); } }else if(wParam==VK_F9){ toolbar_switch(); }else if(wParam==VK_F10 || wParam==VK_F11){ fullscreen_toggle(); } //ctrl if(is_control_pressed()){ if(wParam=='S'){ save_chords_file(); }else if(wParam=='F'){ if(!Config::geti()->toolbar_show){ toolbar_switch(1); } Controls::geti()->set_focus("find_edit"); }else if(wParam=='N'){ new_file(); }else if(wParam=='B'){ chordsbase_start(); }else if(wParam==VK_ADD){ change_font_size(+1); }else if(wParam==VK_SUBTRACT){ change_font_size(-1); }else if(wParam==VK_OEM_3){ // znaczek ` cmd_switch(); if(Config::geti()->cmd_show){ Controls::geti()->set_focus("cmd"); Controls::geti()->select_all("cmd"); }else{ Controls::geti()->set_focus("editor"); } }else if(wParam==VK_LEFT){ transpose(-1); }else if(wParam==VK_RIGHT){ transpose(+1); }else if(wParam=='0'||wParam==VK_NUMPAD0){ transpose(-Config::geti()->transposed); } } return true; //przechwycenie }
void App::event_button(WPARAM wParam){ string name = ""; if(wParam>=1 && wParam<=Controls::geti()->controls.size()){ name = Controls::geti()->get_button_name(wParam); }else{ name = Controls::geti()->get_menu_name(wParam); } if(name.length()==0) return; if(name == "new"){ //nowy new_file(); }else if(name == "load"){ //wczytaj if(!Config::geti()->toolbar_show){ toolbar_switch(1); } string str2 = Controls::geti()->get_text("filename_edit"); if(str2.length()==0){ IO::geti()->echo("Podaj nazwê pliku."); }else{ open_chords_file(str2); } }else if(name == "save"){ //zapisz save_chords_file(); }else if(name == "analyze"){ //analizuj analyze(); }else if(name == "replace"){ //zamieñ if(!Config::geti()->toolbar_show){ toolbar_switch(1); return; } zamien(); }else if(name == "find"){ //znajdŸ if(!Config::geti()->toolbar_show){ toolbar_switch(1); return; } znajdz(); }else if(name == "undo"){ undo->revert(); }else if(name == "base"){ //baza akordów chordsbase_start(); }else if(name == "autoscroll"){ //autoscroll autoscroll_switch(); }else if(name == "reload"){ open_chords_file(Config::geti()->opened_file); }else if(name == "config"){ ShellExecute(0,"open",Config::geti()->config_filename.c_str(),"",0,SW_SHOW); }else if(name == "quick_replace"){ quick_replace(); }else if(name == "remove_chords"){ usun_akordy(); }else if(name == "remove_alt"){ usun_wersje(); }else if(name == "add_chord"){ dodaj_nawias(); }else if(name == "font++"){ change_font_size(+1); }else if(name == "font--"){ change_font_size(-1); }else if(name == "format_text"){ refresh_text(); }else if(name == "fullscreen"){ fullscreen_toggle(); }else if(name == "autoscroll_wait"){ autoscroll_on(); }else if(name == "autoscroll_nowait"){ autoscroll_nowait(); }else if(name == "autoscroll_off"){ autoscroll_off(); IO::geti()->echo("Autoscroll wy³¹czony"); }else if(name == "autoscroll_slower"){ autoscroll_nowait(+Config::geti()->autoscroll_interval*0.25); }else if(name == "autoscroll_faster"){ autoscroll_nowait(-Config::geti()->autoscroll_interval*0.2); }else if(name == "transpose+5"){ transpose(+5); }else if(name == "transpose++"){ transpose(+1); }else if(name == "transpose--"){ transpose(-1); }else if(name == "transpose-5"){ transpose(-5); }else if(name == "transpose0"){ transpose(-Config::geti()->transposed); }else if(name == "alt"){ dodaj_alternatywne(); }else if(name == "log"){ ShellExecute(0, "open", Config::geti()->log_filename.c_str(), "", 0, SW_SHOW); }else if(name == "associate_files"){ associate_files(); }else if(name == "help"){ show_help(); }else if(name == "info"){ stringstream ss; ss<<Config::geti()->program_name<<endl; ss<<"wersja "<<version<<endl; IO::geti()->message_box("O programie",ss.str()); }else if(name == "cmd_toggle"){ cmd_switch(); }else if(name == "toolbar_toggle"){ toolbar_switch(); }else if(name == "scroll_to_begin"){ set_scroll(0); }else if(name == "scroll_to_end"){ SendMessage(Controls::geti()->find("editor"), WM_VSCROLL, SB_BOTTOM, 0); }else if(name == "save_pattern"){ save_pattern(); }else if(name == "insert_pattern"){ insert_pattern(); }else if(name == "exit"){ DestroyWindow(main_window); }else{ IO::geti()->error("Zdarzenie nie zosta³o obs³u¿one: "+name); } }