Example #1
0
static void onSize(HWND, UINT state, int cx, int cy)
{
    if (state == SIZE_MINIMIZED) {
        bMaximised = false;
    } else {
        bool bSizeChanged = false;

        if (ChatActivated()) {
            MoveWindow(GetChatWindow(), 0, cy - 32, cx, 32, FALSE);
        }

        if (state == SIZE_MAXIMIZED) {
            if (!bMaximised) {
                bSizeChanged = true;
            }
            bMaximised = true;
        }
        if (state == SIZE_RESTORED) {
            if (bMaximised) {
                bSizeChanged = true;
            }
            bMaximised = false;
        }

        if (bSizeChanged) {
            refreshWindow(true);
        } else {
            refreshWindow(false);
        }
    }
}
Example #2
0
void FBReader::tryShowFootnoteView(const std::string &id, const std::string &type) {
    if (type == "external") {
        openLinkInBrowser(id);
    } else if (type == "internal") {
        if (myMode == BOOK_TEXT_MODE && !myModel.isNull()) {
            BookModel::Label label = myModel->label(id);
            if (!label.Model.isNull()) {
                if (label.Model == myModel->bookTextModel()) {
                    bookTextView().gotoParagraph(label.ParagraphNumber);
                } else {
                    FootnoteView &view = ((FootnoteView&)*myFootnoteView);
                    view.setModel(label.Model);
                    setMode(FOOTNOTE_MODE);
                    view.gotoParagraph(label.ParagraphNumber);
                }
                setHyperlinkCursor(false);
                refreshWindow();
            }
        }
    } else if (type == "book") {
        DownloadBookRunnable downloader(id);
        downloader.executeWithUI();
        if (downloader.hasErrors()) {
            downloader.showErrorMessage();
        } else {
            shared_ptr<Book> book;
            createBook(downloader.fileName(), book);
            if (!book.isNull()) {
                Library::Instance().addBook(book);
                openBook(book);
                refreshWindow();
            }
        }
    }
}
	void ChooseWindowPushButton::stopMouseCapture()
	{
		if(!mSearching)
			return;

		mSearching = false;
		update();

	#ifdef Q_WS_WIN
		if(mPreviousCursor)
			SetCursor(mPreviousCursor);

		if(mLastFoundWindow)
			refreshWindow(mLastFoundWindow);

		foreach(QWidget *widget, qApp->topLevelWidgets())
			widget->setWindowOpacity(1.0f);
	#endif
	#ifdef Q_WS_X11
		XUngrabPointer(QX11Info::display(), CurrentTime);

		if(mMainWindow)
			mMainWindow->showNormal();
	#endif

		nativeEventFilteringApp->removeNativeEventFilter(this);

		emit searchEnded(mLastFoundWindow);
	}
Example #4
0
void FBReader::tryShowFootnoteView(const std::string &id, bool external) {
	if (external) {
		shared_ptr<ProgramCollection> collection = webBrowserCollection();
		if (!collection.isNull()) {
			shared_ptr<Program> program = collection->currentProgram();
			if (!program.isNull()) {
				program->run("openLink", id);
			}
		}
	} else {
		if ((myMode == BOOK_TEXT_MODE) && (myModel != 0)) {
			BookModel::Label label = myModel->label(id);
			if (!label.Model.isNull()) {
				if (label.Model == myModel->bookTextModel()) {
					bookTextView().gotoParagraph(label.ParagraphNumber);
				} else {
					FootnoteView &view = ((FootnoteView&)*myFootnoteView);
					view.setModel(label.Model);
					setMode(FOOTNOTE_MODE);
					view.gotoParagraph(label.ParagraphNumber);
				}
				setHyperlinkCursor(false);
				refreshWindow();
			}
		}
	}
}
Example #5
0
//this is a setter function to change the color scheme
//it also handles all the regeneration and refreshing
void MandelbrotViewer::setColorScheme(int newScheme) {
    scheme = newScheme;
    initPalette();
    changeColor();
    updateMandelbrot();
    refreshWindow();
}
Example #6
0
void FBReader::initWindow() {
	ZLApplication::initWindow();
	trackStylus(true);

	MigrationRunnable migration;
	if (migration.shouldMigrate()) {
		ZLDialogManager::instance().wait(ZLResourceKey("migrate"), migration);
	}

	if (!myBookAlreadyOpen) {
		BookDescriptionPtr description;
		if (!myBookToOpen.empty()) {
			createDescription(myBookToOpen, description);
		}
		if (description.isNull()) {
			ZLStringOption bookName(ZLCategoryKey::STATE, STATE, BOOK, "");
			description = BookDescription::getDescription(bookName.value());
		}
		if (description.isNull()) {
			description = BookDescription::getDescription(helpFileName(ZLibrary::Language()));
		}
		if (description.isNull()) {
			description = BookDescription::getDescription(helpFileName("en"));
		}
		openBook(description);
	}
	refreshWindow();

//	ZLTimeManager::instance().addTask(new TimeUpdater(*this), 1000);
}
Example #7
0
void FBReader::tryShowFootnoteView(const std::string &id, const std::string &type) {
	if (type == "external") {
		shared_ptr<ProgramCollection> collection = webBrowserCollection();
		if (!collection.isNull()) {
			shared_ptr<Program> program = collection->currentProgram();
			if (!program.isNull()) {
				program->run("openLink", id);
			}
		}
	} else if (type == "internal") {
		if (((myMode == BOOK_TEXT_MODE) || (myMode == FOOTNOTE_MODE) || (myMode == HYPERLINK_NAV_MODE)) && (myModel != 0)) {
			BookModel::Label label = myModel->label(id);
			if (!label.Model.isNull()) {
				if ((myMode != FOOTNOTE_MODE) && (label.Model == myModel->bookTextModel())) {
					bookTextView().gotoParagraph(label.ParagraphNumber);
				} else {
					FootnoteView &view = ((FootnoteView&)*myFootnoteView);
					view.setModel(label.Model, myModel->description()->language());
					setMode(FOOTNOTE_MODE);
					view.gotoParagraph(label.ParagraphNumber);
				}
				setHyperlinkCursor(false);
				refreshWindow();
			}
		}
	} else if (type == "book") {
		DownloadBookRunnable downloader(id);
		downloader.executeWithUI();
		if (downloader.hasErrors()) {
			downloader.showErrorMessage();
		} else {
			openFile(downloader.fileName());
		}
	}
}
Example #8
0
/**
  new WDT
  */
void Window::newWDT()
{
    wdtPath = QFileDialog::getSaveFileName(this, "Select a path for new WDT", QString());
    wdtPathSaveTo = wdtPath;
    loadedWDT = Wdt();
    refreshWindow();
}
Example #9
0
void FBReader::initWindow() {
	ZLApplication::initWindow();
	trackStylus(true);

	MigrationRunnable migration;
	if (migration.shouldMigrate()) {
		ZLDialogManager::Instance().wait(ZLResourceKey("migrate"), migration);
	}

	if (!myBookAlreadyOpen) {
		shared_ptr<Book> book;
		if (!myBookToOpen.empty()) {
			createBook(ZLFile(myBookToOpen), book);
		}
		if (book.isNull()) {
			const BookList &books = Library::Instance().recentBooks();
			if (!books.empty()) {
				book = books[0];
			}
		}
		if (book.isNull()) {
			book = BooksDBUtil::getBook(helpFileName(ZLibrary::Language()));
		}
		if (book.isNull()) {
			book = BooksDBUtil::getBook(helpFileName("en"));
		}
		openBook(book);
	}
	refreshWindow();

	ZLTimeManager::Instance().addTask(new TimeUpdater(), 1000);
}
Example #10
0
void FBReader::openFile(const ZLFile &file) {
	shared_ptr<Book> book;
	createBook(file, book);
	if (!book.isNull()) {
		openBook(book);
		refreshWindow();
	}
}
Example #11
0
void FBReader::openFile(const std::string &filePath) {
    shared_ptr<Book> book;
    createBook(filePath, book);
    if (!book.isNull()) {
        openBook(book);
        refreshWindow();
    }
}
Example #12
0
void FBReader::openFile(const std::string &fileName) {
	BookDescriptionPtr description;
	createDescription(fileName, description);
	if (!description.isNull()) {
		openBook(description);
		refreshWindow();
	}
}
Example #13
0
//sets the rotation and regenerates the mandelbrot
void MandelbrotViewer::setRotation(double radians) {
    rotation = radians;
    if (rotation >= 2 * PI) rotation -= 2 * PI;
    else if (rotation < 0) rotation += 2 * PI;
    generate();
    resetView();
    updateMandelbrot();
    refreshWindow();
}
Example #14
0
static void eventHandler(objectKey key, windowEvent *event)
{
	int x = 0;
	int y = 0;

	// Check for window events.
	if (key == window)
	{
		// Check for window refresh
		if (event->type == EVENT_WINDOW_REFRESH)
			refreshWindow();

		// Check for the window being closed
		else if (event->type == EVENT_WINDOW_CLOSE)
			windowGuiStop();
	}

	// Only go through the array of buttons if the event was a mouse click
	else if (event->type == EVENT_MOUSE_LEFTUP)
	{
		for (x = 0; x < GRID_DIM; x++)
		{
			for (y = 0; y < GRID_DIM; y++)
			{
				if (key == gridButtons[x][y])
				{
					// If this spot is empty, invoke the clickEmpties function
					if (mineField[x][y] == -1)
					{
						clickEmpties(x, y);
					}
					else
					{
						if (mineField[x][y] == 9)
						{
							gameOver(0);
						}
						else
						{
							uncover(x, y);

							if (numUncovered >=
								((GRID_DIM * GRID_DIM) - NUM_MINES))
							{
								gameOver(1);
							}
						}
					}

					return;
				}
			}
		}
	}
}
Example #15
0
void MandelbrotViewer::lockColor() {
    if (color_locked) {
        color_locked = false;
        initPalette();
        changeColor();
        updateMandelbrot();
        refreshWindow();
    } else {
        color_locked = true;
    }
}
Example #16
0
/**
  load a WDT and ask for refreshing the window
  */
void Window::loadWDT()
{
    QString wdtNewPath = QFileDialog::getOpenFileName(this, "Open WDT", QString(), "WDT (*.wdt)");
    if (wdtNewPath != wdtPath)
    {
        wdtPath = wdtNewPath;
        wdtPathSaveTo = wdtPath;
        loadedWDT = Wdt(wdtPath.toStdString());
        refreshWindow();
    }
}
Example #17
0
/**
 * Graphic Character window activation handler
 */
void gcActivateHandler(struct panelw *p)
{
    const char *c;

    c = lcdGetGC(p->lcd, p->gcn);
    memcpy(p->gc, c, 8);

    snprintf(p->title, 100, "C: %d", p->gcn);

    gcPrintHex(p->next, p->gc);
    gcPrintGC(p);
    refreshWindow(p, p->col, p->row);
}
Example #18
0
void ZLApplication::setView(shared_ptr<ZLView> view) {
    if (view.isNull()) {
        return;
    }

    if (!myViewWidget.isNull()) {
        myViewWidget->setView(view);
        resetWindowCaption();
        refreshWindow();
    } else {
        myInitialView = view;
    }
}
Example #19
0
static void onExitSizeMove(HWND)
{
    RECT rect;

    GetClientRect(hScrnWnd, &rect);
    if (rect.right != nPrevWidth || rect.bottom != nPrevHeight) {
        refreshWindow(true);
    }

    GetWindowRect(hScrnWnd, &rect);
    nWindowPosX = rect.left;
    nWindowPosY = rect.top;
}
	void ChooseWindowPushButton::foundWindow(const WindowHandle &handle)
	{
		if(!isWindowValid(handle))
			return;

		if(mLastFoundWindow)
			refreshWindow(mLastFoundWindow);

		highlightWindow(handle);

		mLastFoundWindow = handle;

		emit foundValidWindow(handle);
	}
void Screenshoter::captureArea(int delay)
{
	//Give some time for desktop repainting in case delay=0
	delay = (delay == 0) ? 200 : delay*1000;
	grabAreaWidget_ = new GrabAreaWidget();
	if(grabAreaWidget_->exec() == QDialog::Accepted) {
		QTimer::singleShot(delay, this, SLOT(shootArea()));
	}
	else {
		delete grabAreaWidget_;
		grabAreaWidget_ = 0;
		qApp->desktop()->repaint();
		emit refreshWindow();
	}
}
Example #22
0
void ZLApplication::setView(shared_ptr<ZLView> view) {
//	AppLog("ZLApplication::setView");
	if (view.isNull()) {
		return;
	}
//	AppLog("ZLApplication::setView qq");
	if (!myViewWidget.isNull()) {
//		AppLog("ZLApplication::setView ww");
		myViewWidget->setView(view);
		resetWindowCaption();
		refreshWindow();
	} else {
//		AppLog("ZLApplication::setView ee");
		myInitialView = view;
	}
}
Example #23
0
LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message,
                                 WPARAM wParam, LPARAM lParam)
{
    /**   process system messages   **/
    switch (message)
    {
        // when window is first created
        case WM_CREATE:
            // start timer running
            // with an ID of ID_TIMER (macro)
            // 20 millisecond intervals
            // and no callback function (thus we'll get a message instead)
            SetTimer(hwnd, ID_TIMER, 10, 0);
            break;
        // message from timer "ID_TIMER"
        case WM_TIMER:
            setUpdateRegion(hwnd); // add rectangle to update region
            updateGame(hwnd);     // do the game math update all rectangles
            UpdateWindow(hwnd);  // send WM_PAINT if update region is not empty
            break;
        // whenever the mouse moves over our window
        case WM_MOUSEMOVE:
            // store mouse position
            mpoint_x = MAKEPOINTS(lParam);
            // update paddle rectangle immediately
            updatePaddle();
            break;
        // sent when window is being closed
        case WM_DESTROY:
            cleanUp();
            PostQuitMessage(0);    // send a WM_QUIT a 0 to the message queue
            break;
        // the system message to paint the update region
        case WM_PAINT:
            // paint all rectangles to update region
            refreshWindow(hwnd);
            break;
        // for messages that we don't deal with use the default window procedure
        default:
            return DefWindowProc(hwnd, message, wParam, lParam);
    }

    return 0;
}
Example #24
0
void FBReader::setMode(ViewMode mode) {
    if (mode == myMode) {
        return;
    }

    if (mode != BOOK_TEXT_MODE) {
        myActionOnCancel = RETURN_TO_TEXT_MODE;
    }

    myPreviousMode = myMode;
    myMode = mode;

    switch (myMode) {
    case BOOK_TEXT_MODE:
        setHyperlinkCursor(false);
        ((ZLTextView&)*myBookTextView).forceScrollbarUpdate();
        setView(myBookTextView);
        break;
    case CONTENTS_MODE:
        ((ContentsView&)*myContentsView).gotoReference();
        setView(myContentsView);
        break;
    case FOOTNOTE_MODE:
        setView(myFootnoteView);
        break;
    case LIBRARY_MODE:
    {
        shared_ptr<Book> currentBook = myModel->book();
        ((LibraryView&)*myLibraryByAuthorView).showBook(currentBook);
        ((LibraryView&)*myLibraryByTagView).showBook(currentBook);
        showLibraryView();
        break;
    }
    case BOOKMARKS_MODE:
        break;
    case NETWORK_LIBRARY_MODE:
        setView(myNetworkLibraryView);
        break;
    case UNDEFINED_MODE:
    case ALL_MODES:
        break;
    }
    refreshWindow();
}
void Screenshoter::shootArea()
{
	if(!grabAreaWidget_) {
		return;
	}
	QPixmap pix;
	const QRect rect = grabAreaWidget_->getRect();
	delete grabAreaWidget_;
	grabAreaWidget_ = 0;

	if(rect.isValid()) {
		qApp->desktop()->repaint();
		qApp->beep();
		pix = QPixmap::grabWindow(QApplication::desktop()->winId(), rect.x(), rect.y(), rect.width(), rect.height());
	}

	if(!pix.isNull())
		emit pixmapReady(pix);
	else
		emit refreshWindow();
}
Example #26
0
static void dispatchMessage(FrameworkWindow *window, struct IntuiMessage *msg) {
  switch(msg->Class) {
    case IDCMP_MENUPICK:
      invokeMenuHandler(window, (ULONG)msg->Code);
      break;
    case IDCMP_REFRESHWINDOW:
      refreshWindow(window);
      break;
    case IDCMP_CLOSEWINDOW:
      tryToCloseWindow(window);
      break;
    case IDCMP_GADGETUP:
      invokeGadgetUpHandler(window, (struct Gadget*)msg->IAddress, msg->Code);
      break;
    case IDCMP_MOUSEBUTTONS:
      invokeClickHandler(window, msg->MouseX, msg->MouseY);
      break;
    case IDCMP_NEWSIZE:
      resizeWindow(window);
      break;
  }
}
Example #27
0
void ofApp::toggleFullscreen()
{
    mFullscreen = !mFullscreen;
    refreshWindow();
}
int displayStats(char *filename) {
  Bool   done = False;
  XEvent curEvent;
  char   c;
  long   event_mask = 0xFFFFFFFF;
  long   nBuf = 2;
  int    i;

  /* Load data */
  FILE *fp = fopen(filename,"r");
  if (!fp) {
    printf("Nothing to draw\n");
    return -1;
  }
  fscanf(fp, "numR=%d\n", &numR);
  r                 = malloc(sizeof(float)*numR);
  mean_elongation   = malloc(sizeof(float)*numR);
  mean_polarization = malloc(sizeof(float)*numR);
  std_elongation    = malloc(sizeof(float)*numR);
  std_polarization  = malloc(sizeof(float)*numR);
  for (i=0; i < numR; i++)
    fscanf(fp,"r=%f,mean_elongation=%f,std_elongation=%f,mean_polarization=%f,std_polarization=%f\n",
          &r[i],&mean_elongation[i],&std_elongation[i],
          &mean_polarization[i],&std_polarization[i]);
  fclose(fp);
  minr = min(r,numR);
  maxr = max(r,numR);
  minElongation = min(mean_elongation,numR);
  maxElongation = max(mean_elongation,numR);
  minPolarization = min(mean_polarization,numR);
  maxPolarization = max(mean_polarization,numR);
  
  /* initialize the window  */
  initWindow( 600, 400 );

  drawFigure();

  while(!done) {

    /** Draw stuff here **/
    /*
    if (mode == MOVIE_MODE) {
      t2 = get_time_sec();
      if (t2-t1 > secondsPerFrame && file->curFrame < file->numFrames) {
        readFrame(Px,Py,Vx,Vy,file);
        drawFigure();
        t1 = t2;
      }
    }
    */

    usleep( 33 ); // sleep a little

    // check for events
    if(XCheckWindowEvent(curDisplay, curWindow, event_mask, &curEvent)) {

      switch (curEvent.type) {

      case KeyPress:
        /*
           access string using XLookupString(*event,*char,numChars,NULL,NULL)
        */
        if(XLookupString((XKeyEvent *)&curEvent, &c, 1, NULL, NULL) == 1) {
          switch(c) {
          case 'q':
	    // quit
	    done = True;
	    break;
          default:
            break;
          }
        }
        break;

      case Expose:
        refreshWindow();
        break;

      default:
       break;
      } // end switch over event type
    } // end if event
  } // end while

  closeWindow(nBuf);
  cleanup();
  return(0);
} // end displayStats
Example #29
0
//enables an overlay that dims the screen and displays controls/stats/etc.
void MandelbrotViewer::enableOverlay(bool enable) {
    double angle = rotation * 180 / PI;
    if (angle > 180) angle -= 360;
    sf::Text controls;
    sf::Text stats;
    if (enable) {
        //set up the controls part
        controls.setFont(font);
        controls.setString("                 Help Menu (H)\n"
                        "Controls\n"
                        "------------------------------------------------\n"
                        "Left/Right arrows - Change colors\n"
                        "Up/Down arrows    - Increase/decrease iterations\n"
                        "Click and Drag    - Move around\n"
                        "Numbers 1-7       - Change color scheme\n"
                        "Scroll            - Zoom in/out\n"
                        "H                 - Help menu\n"
                        "S                 - Save image\n"
                        "R                 - Reset\n"
                        "L                 - Lock Colors\n"
                        "Q                 - Quit\n"
                        "Page up           - Rotate counter-clockwise\n"
                        "Page down         - Rotate clockwise\n"
                        "Home              - Reset rotation\n"
                        "------------------------------------------------\n");
        controls.setCharacterSize(24);
        controls.setFillColor(sf::Color::White);
        controls.setPosition(40, 20);

        //set up the stats part
        std::stringstream ss;
        ss << std::fixed << std::setprecision(20);
        ss << "Resolution: " << res_width << "x" << res_height << "\n\n";
        ss << "Coordinates: \n";
        ss << "x: " << std::setw(23) << area.left << "  y: " << std::setw(23) << area.top << "\n";
        ss << "   " << std::setw(23) << area.left + area.width << "     " << std::setw(23) << area.top + area.height;
        ss << std::defaultfloat;
        int zoom_level = log2(2.0/area.width);
        ss << "\n\nZoom level: " << zoom_level;
        if (color_locked)
            ss << "\t\t\t\t\tColor is locked";
        else
            ss << "\t\t\t\t\tColor is unlocked";
		ss << "\n\nIterations: " << max_iter << std::fixed << std::setprecision(0);
        ss << "\n\nRotation: " << angle << " degrees";

        stats.setFont(font);
        stats.setString(ss.str());
        stats.setCharacterSize(24);
        stats.setPosition(40, 485);

        //set up the screen fade
        sf::RectangleShape rectangle;
        rectangle.setSize(sf::Vector2f(res_width, res_height));
        rectangle.setFillColor(sf::Color(0, 0, 0, 192));
        rectangle.setPosition(0, 0);

        //draw to the screen
        window->draw(sprite);
        window->draw(rectangle);
        window->draw(controls);
        window->draw(stats);
        window->display();
    } else {
        refreshWindow();
    }
}
Example #30
0
static void eventHandler(objectKey key, windowEvent *event)
{
	int status = 0;
	int selected = 0;
	char *fullName = NULL;
	char *dirName = NULL;

	// Check for window events.
	if (key == window)
	{
		// Check for window refresh
		if (event->type == EVENT_WINDOW_REFRESH)
			refreshWindow();

		// Check for the window being closed
		else if (event->type == EVENT_WINDOW_CLOSE)
			windowGuiStop();
	}

	else if ((key == mapList) && (event->type & EVENT_SELECTION) &&
		(event->type & EVENT_MOUSE_DOWN))
	{
		if (windowComponentGetSelected(mapList, &selected) < 0)
			return;
		if (loadMap(mapListParams[selected].text) < 0)
			return;
		makeKeyArray(selectedMap);
		updateKeyDiag(selectedMap);
	}

	else if ((key == saveButton) && (event->type == EVENT_MOUSE_LEFTUP))
	{
		fullName = malloc(MAX_PATH_NAME_LENGTH);
		if (!fullName)
			return;

		findMapFile(selectedMap->name, fullName);

		status = windowNewFileDialog(window, _("Save as"),
			_("Choose the output file:"), cwd, fullName, MAX_PATH_NAME_LENGTH,
			0);
		if (status != 1)
		{
			free(fullName);
			return;
		}

		status = saveMap(fullName);
		if (status < 0)
		{
			free(fullName);
			return;
		}

		// Are we working in a new directory?
		dirName = dirname(fullName);
		if (dirName)
		{
			strncpy(cwd, dirName, MAX_PATH_LENGTH);
			free(dirName);
		}

		free(fullName);

		if (getMapNameParams() < 0)
			return;

		windowComponentSetData(mapList, mapListParams, numMapNames,
			1 /* redraw */);

		selectMap(selectedMap->name);

		windowNewInfoDialog(window, _("Saved"), _("Map saved"));
	}

	else if ((key == defaultButton) && (event->type == EVENT_MOUSE_LEFTUP))
	{
		if (windowComponentGetSelected(mapList, &selected) < 0)
			return;
		if (setMap(mapListParams[selected].text) < 0)
			return;
		windowComponentSetData(currentNameLabel, mapListParams[selected].text,
			strlen(mapListParams[selected].text), 1 /* redraw */);
	}

	// Check for the window being closed by a GUI event.
	else if ((key == closeButton) && (event->type == EVENT_MOUSE_LEFTUP))
		windowGuiStop();
}