示例#1
0
void TFileList::HandleEvent (TEvent& e)
{
  int oldpos=pos;
  TListBox::HandleEvent (e);
  if (oldpos!=pos)
    doOnSelectFile ();
  TRect a;
  getClientArea (a, 1);
  if ((e.type&evMouseUp) && a.contain (e.pos))
    doOnChangeDir ();
}
示例#2
0
// draw
//---------------------------------------------------------------------------
void View::draw(Surface& surface)
{
    assert(this != 0);

    if (!getVisible())
        return;

    currentscreen = &surface; // hack
    Surface* viewArea = getViewArea(surface);
    Surface* clientArea = getClientArea(surface);

    if ( backgroundColor != NoColor )
    {
        viewArea->fill( backgroundColor );
    }

    if (getShowStatus())
    {
        drawStatus(*clientArea);
    }

    // Draw all non-selected components.
    ComponentsIterator i;
    for ( i=components.begin(); i != components.end(); i++)
    {
        if (*i != focusComponent)
        {
            (*i)->draw(*clientArea);
        }
    }

    // Now draw the selected component.
    if (focusComponent != 0)
    {
        focusComponent->draw(*clientArea);
    }

    if (getBordered())
    {
        drawTitle(*viewArea);
        drawBorder(*viewArea);
    }

    delete viewArea;
    delete clientArea;
} // end draw
示例#3
0
文件: Window.cpp 项目: bog2k3/bugs
void Window::draw(RenderContext const &ctx, glm::vec3 frameTranslation, glm::vec2 frameScale) {
	glm::ivec3 trans(frameTranslation);
	// draw frame
	glm::vec2 scaledSize = getSize();
	scaledSize.x *= frameScale.x;
	scaledSize.y *= frameScale.y;
	Shape2D::get()->drawRectangleFilled(vec3xy(trans), frameTranslation.z, scaledSize, GuiTheme::getWindowColor());
	Shape2D::get()->drawRectangle(vec3xy(trans), frameTranslation.z, scaledSize, GuiTheme::getWindowFrameColor());

	// draw client area frame:
	glm::vec2 clientOffset, clientSize;
	getClientArea(clientOffset, clientSize);
	clientSize.x *= frameScale.x;
	clientSize.y *= frameScale.y;
	Shape2D::get()->drawRectangleFilled(vec3xy(trans)+clientOffset, frameTranslation.z+0.1f,
			clientSize, GuiTheme::getClientColor());
	Shape2D::get()->drawRectangle(vec3xy(trans)+clientOffset, frameTranslation.z+0.1f,
			clientSize, GuiTheme::getClientFrameColor());

	// now draw contents:
	GuiContainerElement::draw(ctx, glm::vec3(trans)+glm::vec3(0,0,0.5f), frameScale);
}
void
HippoAbstractWindow::moveResizeWindow(int x, int y, int width, int height)
{
    x_ = x;
    y_ = y;
    width_ = width;
    height_ = height;

    if (window_) {
        HippoRectangle rect;
        getClientArea(&rect);
        convertClientRectToWindowRect(&rect);
#if 0
        g_debug("SIZING: MoveWindow on %s to %d,%d %dx%d (window rect %d,%d %dx%d)",
            HippoUStr(getClassName()).c_str(),
            x, y, width, height, rect.x, rect.y, rect.width, rect.height);
#endif
        MoveWindow(window_, rect.x, rect.y, rect.width, rect.height, TRUE);
    } else {
        g_debug("SIZING: MoveWindow to %d,%d %dx%d prior to window create",
            x, y, width, height);
    }
}
示例#5
0
AboutOneSHOT::AboutOneSHOT(): TWindow(Rect(0,0,300,140), "Acerca de...")
{
  minimumSize = QPoint( Bounds.deltax(), Bounds.deltay() );
  QRect a, r( Bounds );
  r.centeron (Application->Bounds, 1);
  moverel( r.a.x, r.a.y );

  getClientArea (a);

  r = TRect (0,0,64,71);
  r.move (2, (a.deltay()-r.deltay())/2);
  QPixmap *px = new QPixmap (r, pal, pixmapabout, EGA_WHITE);
  px->Align = vaFixedSize+vaLeft+vaTop+vaPreservGapL+vaPreservGapT;
  px->State &=~ stFocusheable;

  r = TRect (r.b.x, a.a.y, a.b.x, a.b.y);
  TLabel *lb = new TLabel (r,
	"\nOne-Shot: Simulador de\n"
	"circuitos digitales\n"
	"para MS-DOS.\n"
	"Copyright (C) Martin\n"
	"Alejandro Ribelotta",
	EGA_BLACK, -1 );
//		EGA_WHITE, EGA_BLACK);
  lb->Align = vaRight+vaTop+vaFixedSize;
  lb->State &=~ stFocusheable;

  r = TRect( 0, 0, 80, 24 );
  r.moverel( a.deltax()-r.deltax()-32, a.deltay()-r.deltay()-16 );
  TTextButton *bOk = new TTextButton( r, "Ok", cmCancel );
  bOk->Align = vaBottom+vaRight+vaPreservGapB+vaPreservGapR+vaFixedSize;

  insert (lb);
  insert (px);
  insert (bOk);
  bOk->GotFocus();
}
bool
HippoAbstractWindow::createWindow(void)
{
    if (!defaultPositionSet_ && (windowStyle_ & WS_OVERLAPPEDWINDOW)) {
        RECT workArea;
        int centerX = 0;
        int centerY = 0;
     
        if (::SystemParametersInfo(SPI_GETWORKAREA, 0, &workArea, 0)) {
            centerX = (workArea.left + workArea.right - getWidth()) / 2;
            centerY = (workArea.bottom + workArea.top - getHeight()) / 2;
        }
        
#if 0
        g_debug("SIZING: work area %d,%d %dx%d centering window at %d,%d",
            workArea.left, workArea.top, workArea.right - workArea.left, 
            workArea.bottom - workArea.top,
            centerX, centerY);
#endif

        x_ = centerX;
        y_ = centerY;
    }

    HippoRectangle rect;
    if (selfSizing_) {
        rect.x = CW_USEDEFAULT;
        rect.y = CW_USEDEFAULT;
        rect.width = CW_USEDEFAULT;
        rect.height = CW_USEDEFAULT;
    } else {
        getClientArea(&rect);
        convertClientRectToWindowRect(&rect);

        /* from this point on, x/y/width/height are defined to match the 
        * actual x/y/width/height we've set on window_, unless we're self sizing
        */
        
        /* Note that WM_SIZE is 
        * sent right away but we ignore it since we haven't set ourselves
        * as window data.
        */
#if 0
        g_debug("SIZING: creating window at window rect %d,%d %dx%d client rect %d,%d %dx%d",
            rect.x, rect.y, rect.width, rect.height,
            x_, y_, width_, height_);
#endif
    }

#if 0
    g_debug("Create window style %x WS_OVERLAPPEDWINDOW=%x WS_VISIBLE=%x WS_DISABLED=%x WS_CHILD=%x WS_POPUP=%x WS_CAPTION=%x WS_SYSMENU=%x WS_MINIMIZEBOX=%x",
        windowStyle_,
        windowStyle_ & WS_OVERLAPPEDWINDOW, windowStyle_ & WS_VISIBLE,
        windowStyle_ & WS_DISABLED, windowStyle_ & WS_CHILD, windowStyle_ & WS_POPUP,
        windowStyle_ & WS_CAPTION,
        windowStyle_ & WS_SYSMENU,
        windowStyle_ & WS_MINIMIZEBOX);
#endif

    window_ = CreateWindowEx(extendedStyle_, className_, title_, windowStyle_,
        rect.x, rect.y, rect.width, rect.height,
        (useParent_ && ui_) ? ui_->getWindow() : (createWithParent_ ? createWithParent_->window_ : NULL), 
        NULL, instance_, NULL);
    if (!window_) {
        hippoDebugLastErr(L"Couldn't create window!");
        return false;
    }

    if (selfSizing_) {
        // Get the default sizes Windows picked,
        // though this is somewhat pointless since right
        // now selfSizing_ is used for common controls
        // and we don't get WM_SIZE/WM_MOVE on those 
        // so won't be keeping this up to date anyhow
        queryCurrentClientRect(&rect);
        x_ = rect.x;
        y_ = rect.y;
        width_ = rect.width;
        height_ = rect.height;
    } else {
        // Sanity check we set what we wanted
        HippoRectangle actual;
        HippoRectangle believed;
        getClientArea(&believed);
        queryCurrentClientRect(&actual);
        if (!hippo_rectangle_equal(&believed, &actual)) {
            g_warning("window class %s not created with expected dimensions, actual %d,%d %dx%d believed %d,%d %dx%d",
                HippoUStr(getClassName()).c_str(),
                actual.x, actual.y, actual.width, actual.height,
                believed.x, believed.y, believed.width, believed.height);
            // Fix up and try to continue
            x_ = actual.x;
            y_ = actual.y;
            width_ = actual.width;
            height_ = actual.height;
        }
    }

    //EnableScrollBar(window_, SB_BOTH, ESB_DISABLE_BOTH);

    hippoSetWindowData<HippoAbstractWindow>(window_, this);
    g_assert(ui_ != NULL);
    ui_->registerMessageHook(window_, this);

    initializeWindow();

    return true;
}