int main(int /*argc*/, char** /*argv*/) { Gtk::Main* pKit = Gtk::Main::instance(); if ( pKit == NULL ) { pKit = new Gtk::Main( 0, NULL ); } // Initialize the thread system if( !Glib::thread_supported() ) { Glib::thread_init(); } // Display the camera selection dialog PGRGuid guid[64]; unsigned int size = 64; bool ok = GetCameras( &guid[0], &size ); if ( ok != true || size <= 0 ) { return -1; } // Create the individual windows FlycapWindow* windows = new FlycapWindow[size]; for ( unsigned int i = 0; i < size; i++ ) { bool ret = windows[i].Run( guid[i] ); if ( ret != true ) { for ( int j=0; j < i; j++) { // Clean up all windows that are already created windows[j].Cleanup(); } delete [] windows; return -1; } } // Start the main Gtk event loop pKit->run(); // This point is reached when the last window alive kills the Gtk::Main loop // Perform cleanup on all the windows for ( unsigned int i = 0; i < size; i++ ) { windows[i].Cleanup(); } delete [] windows; return 0; }
static void GetCameras(INode *inode, Tab<INode *> *list) { const ObjectState &os = inode->EvalWorldState(0); Object *ob = os.obj; if (ob != NULL) { if (ob->SuperClassID() == CAMERA_CLASS_ID) { list->Append(1, &inode); } } int count = inode->NumberOfChildren(); for (int i = 0; i < count; i++) GetCameras(inode->GetChildNode(i), list); }
BOOL CALLBACK AnchorDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam, AnchorObject *th) { TCHAR text[MAX_PATH]; int c, camIndex, i, type; HWND cb; Tab<INode *> cameras; switch (message) { case WM_INITDIALOG: th->ParentPickButton = GetICustButton(GetDlgItem(hDlg, IDC_PICK_PARENT)); th->ParentPickButton->SetType(CBT_CHECK); th->ParentPickButton->SetButtonDownNotify(TRUE); th->ParentPickButton->SetHighlightColor(GREEN_WASH); th->ParentPickButton->SetCheck(FALSE); th->dlgPrevSel = -1; th->hRollup = hDlg; if (th->triggerObject) Static_SetText(GetDlgItem(hDlg, IDC_TRIGGER_OBJ), th->triggerObject->GetName()); th->pblock->GetValue(PB_AN_TYPE, th->iObjParams->GetTime(), type, FOREVER); th->isJump = type == 0; EnableWindow(GetDlgItem(hDlg, IDC_ANCHOR_URL), th->isJump); EnableWindow(GetDlgItem(hDlg, IDC_PARAMETER), th->isJump); EnableWindow(GetDlgItem(hDlg, IDC_BOOKMARKS), th->isJump); EnableWindow(GetDlgItem(hDlg, IDC_CAMERA), !th->isJump); GetCameras(th->iObjParams->GetRootNode(), &cameras); c = cameras.Count(); cb = GetDlgItem(hDlg, IDC_CAMERA); camIndex = -1; for (i = 0; i < c; i++) { // add the name to the list TSTR name = cameras[i]->GetName(); int ind = ComboBox_AddString(cb, name.data()); ComboBox_SetItemData(cb, ind, cameras[i]); if (cameras[i] == th->cameraObject) camIndex = i; } if (camIndex != -1) ComboBox_SelectString(cb, 0, cameras[camIndex]->GetName()); Edit_SetText(GetDlgItem(hDlg, IDC_DESC), th->description.data()); Edit_SetText(GetDlgItem(hDlg, IDC_ANCHOR_URL), th->URL.data()); Edit_SetText(GetDlgItem(hDlg, IDC_PARAMETER), th->parameter.data()); if (pickMode) SetPickMode(th); return TRUE; case WM_DESTROY: if (pickMode) SetPickMode(th); //th->iObjParams->ClearPickMode(); //th->previousMode = NULL; ReleaseICustButton(th->ParentPickButton); return FALSE; case WM_MOUSEACTIVATE: return FALSE; case WM_LBUTTONDOWN: case WM_LBUTTONUP: case WM_MOUSEMOVE: return FALSE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_BOOKMARKS: { // do bookmarks TSTR url, cam, desc; if (GetBookmarkURL(th->iObjParams, &url, &cam, &desc)) { // get the new URL information; Edit_SetText(GetDlgItem(hDlg, IDC_ANCHOR_URL), url.data()); Edit_SetText(GetDlgItem(hDlg, IDC_DESC), desc.data()); } } break; case IDC_CAMERA: if (HIWORD(wParam) == CBN_SELCHANGE) { cb = GetDlgItem(hDlg, IDC_CAMERA); int sel = ComboBox_GetCurSel(cb); INode *rtarg; rtarg = (INode *)ComboBox_GetItemData(cb, sel); th->ReplaceReference(2, rtarg); } break; case IDC_HYPERLINK: th->isJump = IsDlgButtonChecked(hDlg, IDC_HYPERLINK); EnableWindow(GetDlgItem(hDlg, IDC_ANCHOR_URL), th->isJump); EnableWindow(GetDlgItem(hDlg, IDC_PARAMETER), th->isJump); EnableWindow(GetDlgItem(hDlg, IDC_BOOKMARKS), th->isJump); EnableWindow(GetDlgItem(hDlg, IDC_CAMERA), !th->isJump); break; case IDC_SET_CAMERA: th->isJump = !IsDlgButtonChecked(hDlg, IDC_SET_CAMERA); EnableWindow(GetDlgItem(hDlg, IDC_ANCHOR_URL), th->isJump); EnableWindow(GetDlgItem(hDlg, IDC_PARAMETER), th->isJump); EnableWindow(GetDlgItem(hDlg, IDC_BOOKMARKS), th->isJump); EnableWindow(GetDlgItem(hDlg, IDC_CAMERA), !th->isJump); break; case IDC_PICK_PARENT: // Pick an object from the scene // Set the pickmode... switch (HIWORD(wParam)) { case BN_BUTTONDOWN: SetPickMode(th); /* if (th->previousMode) { // reset the command mode th->iObjParams->SetCommandMode(th->previousMode); th->previousMode = NULL; } else { th->previousMode = th->iObjParams->GetCommandMode(); theParentPick.SetAnchor(th); th->iObjParams->SetPickMode(&theParentPick); } */ break; } return TRUE; case IDC_ANCHOR_URL: switch (HIWORD(wParam)) { case EN_SETFOCUS: DisableAccelerators(); break; case EN_KILLFOCUS: EnableAccelerators(); break; case EN_CHANGE: Edit_GetText(GetDlgItem(hDlg, IDC_ANCHOR_URL), text, MAX_PATH); th->URL = text; } break; case IDC_DESC: switch (HIWORD(wParam)) { case EN_SETFOCUS: DisableAccelerators(); break; case EN_KILLFOCUS: EnableAccelerators(); break; case EN_CHANGE: Edit_GetText(GetDlgItem(hDlg, IDC_DESC), text, MAX_PATH); th->description = text; } break; case IDC_PARAMETER: switch (HIWORD(wParam)) { case EN_SETFOCUS: DisableAccelerators(); break; case EN_KILLFOCUS: EnableAccelerators(); break; case EN_CHANGE: Edit_GetText(GetDlgItem(hDlg, IDC_PARAMETER), text, MAX_PATH); th->parameter = text; } break; default: return FALSE; } } return FALSE; }