IlvContainer* FileViewerApplication::createMainWindow(const IlvRect& rect) const { return new IlvDockableMainWindow(getDisplay(), getName(), getName(), rect, 0, IlvFalse); } |
void FileViewerApplication::makePanels(){ // Initialize the main window. initMainWindow(); // Initialize the panes. initPanes(); // Initialize the application. configureApplication(); // Update the main window layout. getMainWindow()->updatePanes(IlvTrue); // Show it. getMainWindow()->show(); } |
void FileViewerApplication::initPanes() { // Initialize the menu bar. initMenuBar(); // Initialize the toolbar. initToolBar(); } |
void FileViewerApplication::initToolBar() { IlvToolBar* toolbar = new IlvToolBar(getDisplay(), IlvPoint(0, 0)); // Item Up One Level. toolbar->insertBitmap(getBitmap("upBm")); toolbar->getItem(0)->setCallback(UpOneLevel); toolbar->getItem(0)->setClientData(this); toolbar->getItem(0)->setToolTip("Up One Level"); // Encapsulate the toolbar into a graphic pane. IlvGraphicPane* toolbarPane = new IlvAbstractBarPane("Toolbar", toolbar); // Add the pane to the application on top of the main workspace. getMainWindow()->addRelativeDockingPane(toolbarPane, IlvDockableMainWindow:: GetMainWorkspaceName(), IlvTop); } |
メモ: アイテムのクライアント・データは this に設定され、アプリケーションへのポインターをそのコールバック関数から取得できるようにします(クライアント・データは、アイテムがアクティブにされるときに呼び出されるコールバックの 2 番目のパラメーターです)。 |
static void UpOneLevel(IlvGraphic* g, IlvAny arg) { // Retrieve a pointer on the application. FileViewerApplication* application = (FileViewerApplication*)arg; // Retrieve a pointer on the main window. FileViewerWindow* window = (FileViewerWindow*) application->getMainWindow()->getMainWorkspaceViewPane()->getView(); // Retrieve a pointer on the file viewer. FileViewer* viewer = FileViewerApplication::GetFileViewer(window); if (viewer) { // Find the last selected item of the tree. IlvTreeGadgetItem* item = viewer->getTreeGadget()->getLastSelectedItem(); // And select its parent. if (item && item->getParent() && item->getParent()->getParent()) viewer->getTreeGadget()->selectItem(item->getParent(), IlvTrue, IlvTrue, IlvTrue); } } |
void FileViewerApplication::initMenuBar() { // The menu bar is in fact an IlvToolBar. IlvToolBar* menubar = new IlvToolBar(getDisplay(), IlvPoint(0, 0)); // Add two items menubar->addLabel("File"); menubar->addLabel("Help"); // Create the pane that will encapsulate the menu bar. IlvGraphicPane* menubarPane = new ApplicationMenuBarPane("Menu Bar", menubar); // Change the mode of the menu bar to make it show items on several // rows, if needed. menubar->setConstraintMode(IlvTrue); // Add the pane to the application on top of the main workspace. getMainWindow()->addRelativeDockingPane(menubarPane, IlvDockableMainWindow:: GetMainWorkspaceName(), IlvTop); // Now fill the menus with popup menus. IlvPopupMenu* menu; // Menu File:New / Separator / Exit. menu = new IlvPopupMenu(getDisplay()); menu->addLabel("Exit"); menu->getItem(0)->setCallback(ExitApplication); menu->getItem(0)->setClientData(this); menubar->getItem(0)->setMenu(menu, IlvFalse); // Menu Help:About. menu = new IlvPopupMenu(getDisplay()); menu->addLabel("About"); menubar->getItem(1)->setMenu(menu, IlvFalse); menu->getItem(0)->setCallback(ShowAboutPanel); menu->getItem(0)->setClientData(this); } |
void FileViewerApplication::showVersion() { IlvIInformationDialog dialog(getDisplay(), "VIEWFILE Tutorial"); dialog.moveToMouse(); dialog.showModal(); } |
void FileViewerApplication::configureApplication() { // Create the file viewer window. FileViewerWindow* window = createFileViewerWindow(getMainWindow(), IlvRect(0, 0, 400, 200)); // Replace the view of the main workspace pane with the file viewer window. getMainWindow()->getMainWorkspaceViewPane()->setView(window); // Create the file viewer using the file viewer window. FileViewer* viewer = createFileViewer(window); // Link the file viewer with its window. // This is used in the UpOneLevel callback. SetFileViewer(window, viewer); // Initialize the file viewer. viewer->init(IlvPathName("/")); } |