🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.interviews
Article #222

Creating an X subwindow in InterViews

#222
From: Lee D. Coller
Date: Tue, 11 Aug 1992 17:11
95 lines
2956 bytes
I am trying to create X subwindow of a window using InterViews.  I have
created a descendant class of Window, SubWindow, to implement this.  It
seems to work except for one problem.  When the parent window is resized,
the subwindow gets obscured.  Additional resizes cause the subwindow to
flash, but not to remain visible.  Any help is appreciated.

I'm using IV3.0 with Unidraw (the parent window contains an editor).
Running X11r4 under SCO Unix with Motif.

The code for my SubWindow class follows:

/************************************************************************
 *
 * Subclass of Window which can take a window other than root as ites
 * parent.
 */

#ifndef subwindow_h
#define subwindow_h

#include <InterViews/window.h>

class SubWindow : public Window {
public:
    SubWindow(Glyph*, Window* = nil);
    ~SubWindow();

    virtual void bind();
protected:
    virtual void set_attributes();
    virtual void default_geometry();

private:
    Window *_parent;
};

#endif

/************************************************************************
 *
 * Subwindow implementation.
 */

#include "subwindow.h"

#include <IV-X11/xwindow.h>
#include <InterViews/glyph.h>

#include <InterViews/_enter.h>

SubWindow::SubWindow(Glyph* g, Window* w) : Window(g), _parent(w) {}

SubWindow::~SubWindow() {}

void
SubWindow::bind() {
    if (!_parent) {
	Window::bind();
    } else if (_parent->bound()) {
	WindowRep *r = rep();
	r->do_bind(this, _parent->rep()->xwindow_, r->xpos_, r->ypos_);
    }
}

void
SubWindow::set_attributes() {
    Window::set_attributes();
    WindowRep *w = rep();
    w->xattrmask_ |= CWOverrideRedirect;
    w->xattrs_.override_redirect = true;
}

void
SubWindow::default_geometry() {
    WindowRep *w = rep();
    Display *d = w->display_;

    w->glyph_->request(w->shape_);

    Coord width = w->shape_.requirement(Dimension_X).natural();
    Coord height = w->shape_.requirement(Dimension_Y).natural();
    w->canvas_->size(width, height);

    w->xpos_ = d->to_pixels(w->left_);
    w->ypos_ = _parent->pheight() - d->to_pixels(w->bottom_) - pheight();
    if (w->aligned_) {
	w->xpos_ -= d->to_pixels(w->xalign_ * width);
	w->ypos_ += d->to_pixels(w->yalign_ * height);
    }
}
-- 
-----------------------------------------------------------------
Lee D. Coller (coller@alnitak.usc.edu)		+1 (310) 379-0844
USC Behavioral Technology Labs, 250 N. Harbor Dr. Ste 309
Redondo Beach, California, 90277
Technical Details
Message-ID: <l8ft6aINN3m1@alnitak.usc.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!news

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!news
From: coller@alnitak.usc.edu (Lee D. Coller)
Newsgroups: comp.windows.interviews
Subject: Creating an X subwindow in InterViews
Date: 11 Aug 1992 10:11:38 -0700
Organization: University of Southern California, Los Angeles, CA
Lines: 95
Sender: coller@alnitak.usc.edu (Lee D. Coller)
Distribution: world
Message-ID: <l8ft6aINN3m1@alnitak.usc.edu>
NNTP-Posting-Host: alnitak.usc.edu