void init() { // 1st light source. glEnable(GL_DEPTH_TEST); glLightfv(GL_LIGHT0, GL_DIFFUSE, WHITE); glLightfv(GL_LIGHT0, GL_SPECULAR, WHITE); glMaterialfv(GL_FRONT, GL_SPECULAR, WHITE); glMaterialf(GL_FRONT, GL_SHININESS, 30); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); // 2nd light source. glEnable(GL_DEPTH_TEST); glLightfv(GL_LIGHT1, GL_DIFFUSE, RED); glLightfv(GL_LIGHT1, GL_SPECULAR, RED); glMaterialfv(GL_FRONT, GL_SPECULAR, RED); glMaterialf(GL_FRONT, GL_SHININESS, 30); glEnable(GL_LIGHTING); glEnable(GL_LIGHT1); // Default value t_value = 1.0; // Generates primitives. GenerateList(); }
void processNormalKeys(unsigned char key, int x, int y) { switch (key) { case KEY_LOWER_X: displayCamera.MoveAwayFromOrigin(); break; case KEY_UPPER_X: displayCamera.MoveAwayFromOrigin(); break; case KEY_LOWER_Z: displayCamera.MoveCloserToOrigin(); break; case KEY_UPPER_Z: displayCamera.MoveCloserToOrigin(); break; case KEY_ONE: t_value = 1.00; GenerateList(); break; case KEY_TWO: t_value = 0.33; GenerateList(); break; case KEY_THREE: t_value = 0.11; GenerateList(); break; case KEY_FOUR: t_value = 0.0370; GenerateList(); break; case KEY_FIVE: t_value = 0.0123; GenerateList(); break; default: break; } glutPostRedisplay(); }
int main(int argc, char *argv[]) { if (argc > 1) { if ( 0 == strcmp (argv[1] , "-g") && argc > 2 ) { GenerateList(argv[2]); } else if (0 == strcmp (argv[1] , "-c")) { if (argc < 5) { std::cerr << "Too few parameters for copy mode" << std::endl << std::endl; PrintHelp(); return 1; } std::string strFileList (argv[2]); std::string strSrcPath (argv[3]); std::string strDstPath (argv[4]); CopyList(strFileList, strSrcPath, strDstPath); } else if (0 == strcmp (argv[1] , "-e")) { if (argc < 4) { std::cerr << "Too few parameters for exclude mode" << std::endl << std::endl; PrintHelp(); return 1; } std::string strBaseList (argv[2]); std::string strDiffList (argv[3]); ExcludeList(strBaseList, strDiffList); } else { PrintHelp(); } } else { PrintHelp(); } return 0; }
void DragFunc(HWND hWnd, HDROP hDrop) { int i, numfiles; char filename[1024]; CStringList *sl = new CStringList(); numfiles = DragQueryFile(hDrop, 0xFFFFFFFF, (LPSTR)NULL, 0); for (i = 0; i < numfiles; i++) { DragQueryFile(hDrop, i, filename, sizeof(filename)); sl->Add(filename); } WriteDiskImages(hWnd, sl); delete sl; //display new list of disks stored in flash i = GenerateList(GetDlgItem(hWnd, ID_DISKLIST), GetDlgItem(hWnd, ID_STATUS)); }
void WPassGen::LoadDefaultSettings() { choicePreset->SetSelection(PT_ALPHANUMERIC); choiceType->SetSelection(0); checkboxSkipSimilarChar->SetValue(false); checkboxSkipSwappedChar->SetValue(false); textctrlExtraChar->SetValue(_T("")); spinctrlLength->SetValue(12); spinctrlNumber->SetValue(10); checkboxEnumerate->SetValue(false); presetlist = GetDefaultPresets(); // update dialog logic ResetPresetChoice(); UpdateCheckboxes(); UpdateKeyStrength(); GenerateList(); buttonOK->Disable(); }
void WPassGen::OnButtonGenerate(wxCommandEvent& WXUNUSED(event)) { GenerateList(); }
WPassGen::WPassGen(wxWindow* parent, bool _standalone, int id, const wxString& title, const wxPoint& pos, const wxSize& size, long WXUNUSED(style)) : wxDialog(parent, id, title, pos, size, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxTHICK_FRAME), standalone(_standalone) { { #include "art/pwgen-16.h" #include "art/pwgen-22.h" #include "art/pwgen-32.h" #include "art/pwgen-48.h" wxIconBundle progicon; progicon.AddIcon(wxIconFromMemory(pwgen_16_png)); progicon.AddIcon(wxIconFromMemory(pwgen_22_png)); progicon.AddIcon(wxIconFromMemory(pwgen_32_png)); progicon.AddIcon(wxIconFromMemory(pwgen_48_png)); SetIcons(progicon); } // begin wxGlade: WPassGen::WPassGen sizer2_staticbox = new wxStaticBox(this, -1, _("Generator Options")); const wxString* choicePreset_choices = NULL; choicePreset = new wxChoice(this, myID_PRESET, wxDefaultPosition, wxDefaultSize, 0, choicePreset_choices, 0); buttonPresetAdd = new wxBitmapButton(this, myID_PRESET_ADD, wxNullBitmap); buttonPresetRemove = new wxBitmapButton(this, myID_PRESET_REMOVE, wxNullBitmap); const wxString* choiceType_choices = NULL; choiceType = new wxChoice(this, myID_TYPE, wxDefaultPosition, wxDefaultSize, 0, choiceType_choices, 0); checkboxSkipSimilarChar = new wxCheckBox(this, myID_SKIPSIMILARCHAR, _("Don't use 0/O and 1/l.")); checkboxSkipSwappedChar = new wxCheckBox(this, myID_SKIPSWAPPEDCHAR, _("Don't use z/y.")); textctrlExtraChar = new wxTextCtrl(this, myID_TEXT_EXTRACHAR, wxEmptyString); spinctrlLength = new wxSpinCtrl(this, myID_LENGTH, wxT("12"), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 6, 100); textctrlStrength = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY); spinctrlNumber = new wxSpinCtrl(this, myID_NUMBER, wxT("10"), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 1000); checkboxEnumerate = new wxCheckBox(this, myID_ENUMERATE, _("Enumerate")); buttonGenerate = new wxButton(this, myID_GENERATE, _("&Generate")); listctrlPasslist = new wxListCtrl(this, myID_PASSLIST, wxDefaultPosition, wxDefaultSize, wxLC_LIST | wxSUNKEN_BORDER); textctrlPasslist = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxTE_READONLY); buttonOK = new wxButton(this, wxID_OK, wxEmptyString); buttonCancel = new wxButton(this, wxID_CANCEL, wxEmptyString); buttonAbout = new wxButton(this, wxID_ABOUT, _("&About")); buttonClose = new wxButton(this, wxID_CLOSE, wxEmptyString); set_properties(); do_layout(); // end wxGlade // set bitmap from compiled-in PNGs { #include "art/gnome/list-add.h" #include "art/gnome/list-remove.h" buttonPresetAdd->SetBitmapLabel(wxBitmapFromMemory(gnome_list_add_png)); buttonPresetRemove->SetBitmapLabel(wxBitmapFromMemory(gnome_list_remove_png)); } // insert password type names for (unsigned int pt = 0; pt <= PT_LAST; ++pt) { choiceType->Append(GetTypeName((pass_type)pt)); } // update dialog logic ResetPresetChoice(); UpdateCheckboxes(); UpdateKeyStrength(); GenerateList(); buttonOK->Disable(); }
void WPassGen::LoadSettings(class wxConfigBase* cfg) { // load settings from wxConfig cfg->SetPath(_T("/pwgen")); int preset, type, length, number; bool skip_similar, skip_swapped, enumerate; wxString extrachar; cfg->Read(_T("preset"), &preset, PT_ALPHANUMERIC); cfg->Read(_T("type"), &type, 0); cfg->Read(_T("skip_similar"), &skip_similar, false); cfg->Read(_T("skip_swapped"), &skip_swapped, false); cfg->Read(_T("extrachar"), &extrachar); cfg->Read(_T("length"), &length, 12); cfg->Read(_T("number"), &number, 10); cfg->Read(_T("enumerate"), &enumerate, false); choicePreset->SetSelection(preset); choiceType->SetSelection(type); checkboxSkipSimilarChar->SetValue(skip_similar); checkboxSkipSwappedChar->SetValue(skip_swapped); textctrlExtraChar->SetValue(extrachar); spinctrlLength->SetValue(length); spinctrlNumber->SetValue(number); checkboxEnumerate->SetValue(enumerate); if (cfg->Exists(_T("/pwgen/presets"))) { presetlist.clear(); cfg->SetPath(_T("/pwgen/presets")); for (unsigned int pi = 0; cfg->HasGroup(wxString::Format(_T("%d"), pi)); ++pi) { cfg->SetPath(wxString::Format(_T("%d"), pi)); Preset preset; cfg->Read(_T("name"), &preset.name, _("<unknown>")); cfg->Read(_T("type"), (int*)&preset.type, 0); cfg->Read(_T("skip_similar"), &preset.skip_similar, false); cfg->Read(_T("skip_swapped"), &preset.skip_swapped, false); cfg->Read(_T("extrachar"), &preset.extrachar); cfg->Read(_T("length"), &preset.length, 12); presetlist.push_back(preset); cfg->SetPath(_T("..")); } } else { // Load a list of default presets if none are defined in the config // storage. presetlist = GetDefaultPresets(); } // update dialog logic ResetPresetChoice(); UpdateCheckboxes(); UpdateKeyStrength(); GenerateList(); buttonOK->Disable(); }
// // FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM) // // PURPOSE: Processes messages for the main window. // // WM_COMMAND - process the application menu // WM_PAINT - Paint the main window // WM_DESTROY - post a quit message and return // // LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { HFONT hFont = NULL; HWND hReadButton = NULL; HWND hStatus = NULL; HWND hList = NULL; int i; static char str[512]; LVITEM lvi; CStringList *sl; switch (message) { case WM_COMMAND: { int wmId = LOWORD(wParam); // Parse the menu selections: switch (wmId) { case IDM_ABOUT: DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About); break; case IDM_EXIT: DestroyWindow(hWnd); break; case ID_DISK_READDISK: DialogBox(hInst, MAKEINTRESOURCE(IDD_READDISK), hWnd, reinterpret_cast<DLGPROC>(ReadDiskDlg)); break; case ID_DISK_WRITEDISK: DialogBox(hInst, MAKEINTRESOURCE(IDD_WRITEDISK), hWnd, reinterpret_cast<DLGPROC>(WriteDiskDlg)); break; case ID_FLASH_WRITEIMAGES: sl = new CStringList(); SelectDiskImages(hWnd,sl); WriteDiskImages(hWnd, sl); delete sl; GenerateList(GetDlgItem(hWnd, ID_DISKLIST), GetDlgItem(hWnd, ID_STATUS)); break; case ID_FLASH_ERASECHIP: if (MessageBox(hWnd, "This process could take a long time.\n\nAre you sure you want to erase the entire flash?", "FDSemu", MB_YESNO) == IDYES) { fdsemu->dev->Flash->ChipErase(); GenerateList(GetDlgItem(hWnd, ID_DISKLIST), GetDlgItem(hWnd, ID_STATUS)); } break; case ID_POPUP_INFO: hList = GetDlgItem(hWnd, ID_DISKLIST); //find selected items i = ListView_GetNextItem(hList, -1, LVNI_SELECTED); if (i != -1) { lvi.iItem = i; lvi.iSubItem = 0; lvi.mask = LVIF_PARAM; if (ListView_GetItem(hList, &lvi) == TRUE) { DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_DISKINFO), hWnd, reinterpret_cast<DLGPROC>(DiskInfoDlg), lvi.lParam); GenerateList(GetDlgItem(hWnd, ID_DISKLIST), GetDlgItem(hWnd, ID_STATUS)); } } break; case ID_FLASH_SAVEIMAGE: case ID_POPUP_SAVE: hStatus = GetDlgItem(hWnd, ID_STATUS); hList = GetDlgItem(hWnd, ID_DISKLIST); //find selected items i = ListView_GetNextItem(hList, -1, LVNI_SELECTED); while (i != -1) { lvi.iItem = i; lvi.iSubItem = 0; lvi.mask = LVIF_PARAM; if (ListView_GetItem(hList, &lvi) == TRUE) { SaveDiskImage(hWnd, lvi.lParam); } //check if more are selected i = ListView_GetNextItem(hList, i, LVNI_SELECTED); } break; case ID_POPUP_DELETE: hStatus = GetDlgItem(hWnd, ID_STATUS); hList = GetDlgItem(hWnd, ID_DISKLIST); //find selected items i = ListView_GetNextItem(hList, -1, LVNI_SELECTED); while (i != -1) { lvi.iItem = i; lvi.iSubItem = 0; lvi.mask = LVIF_PARAM; if (ListView_GetItem(hList, &lvi) == TRUE) { //update status bar sprintf(str, "Deleting disk image in slot %d from flash...", lvi.lParam); SetWindowText(hStatus, str); fdsemu->Erase(lvi.lParam); } //check if more are selected i = ListView_GetNextItem(hList, i, LVNI_SELECTED); } //re-read the headers fdsemu->dev->FlashUtil->ReadHeaders(); //display new list of disks stored in flash i = GenerateList(hList, hStatus); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } } break; case WM_PAINT: { PAINTSTRUCT ps; HDC hdc = BeginPaint(hWnd, &ps); // TODO: Add any drawing code that uses hdc here... EndPaint(hWnd, &ps); } break; case WM_CREATE: hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT); SendMessage(hWnd, WM_SETFONT, (WPARAM)hFont, (LPARAM)MAKELONG(TRUE, 0)); hStatus = CreateWindowEx(0, STATUSCLASSNAME, NULL, WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP, 0, 0, 0, 0, hWnd, (HMENU)ID_STATUS, GetModuleHandle(NULL), NULL); hList = CreateWindowEx(WS_EX_CLIENTEDGE, WC_LISTVIEW, NULL, WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_AUTOVSCROLL | LVS_REPORT | LVS_EDITLABELS | LVS_NOCOLUMNHEADER, 10, 10, 300, 300, hWnd, (HMENU)ID_DISKLIST, GetModuleHandle(NULL), NULL); InsertListViewColumns(hList); i = GenerateList(hList,hStatus); if (i >= 0) { sprintf(str, "%d slots used, %d remaining.", fdsemu->dev->Slots - i, i); } else { sprintf(str, "Error reading flash headers."); } SetWindowText(hStatus, str); DragAcceptFiles(hWnd, TRUE); break; case WM_DESTROY: DragAcceptFiles(hWnd, FALSE); PostQuitMessage(0); break; case WM_DROPFILES: DragFunc(hWnd, (HDROP)wParam); /* application-defined function */ break; case WM_NOTIFY: hList = GetDlgItem(hWnd, ID_DISKLIST); // When right button clicked on mouse if ((((LPNMHDR)lParam)->hwndFrom) == hList) { if (ListView_GetSelectedCount(hList) > 0) { switch (((LPNMHDR)lParam)->code) { case NM_RCLICK: POINT cursor; GetCursorPos(&cursor); TrackPopupMenu((HMENU)GetSubMenu(LoadMenu(hInst, MAKEINTRESOURCE(IDR_DISKLISTMENU)), 0), TPM_LEFTALIGN | TPM_RIGHTBUTTON, cursor.x, cursor.y, 0, hWnd, NULL); return(0); } } } return DefWindowProc(hWnd, message, wParam, lParam); case WM_SIZE: RECT rcStatus; int iStatusHeight; int iEditHeight; RECT rcClient; // Size status bar and get height hStatus = GetDlgItem(hWnd, ID_STATUS); SendMessage(hStatus, WM_SIZE, 0, 0); GetWindowRect(hStatus, &rcStatus); iStatusHeight = rcStatus.bottom - rcStatus.top; // Calculate remaining height and size edit GetClientRect(hWnd, &rcClient); iEditHeight = rcClient.bottom - iStatusHeight; hList = GetDlgItem(hWnd, ID_DISKLIST); SetWindowPos(hList, NULL, 0, 0, rcClient.right, iEditHeight, SWP_NOZORDER); ListView_SetColumnWidth(hList, 0, rcClient.right - 22); break; case WM_GETMINMAXINFO: MINMAXINFO* mmi; mmi = (MINMAXINFO*)lParam; mmi->ptMinTrackSize.x = 400; mmi->ptMinTrackSize.y = 400; break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }