#include <pthread.h>
#include <Qt>
#include <QtCore>
#include <QtGui>
#include <QPainter>
#include <QWidget>
#include <QImage>
#define qtApp ((QtApplication *)qApp)
void threadfunc(void *arg);
void AWT_drawline(int x1, int y1, int x2, int y2);
void getQtColorModel();
void Qtexec();
{
public:
QtWindow(int flags,
const char *name = "Sun AWT/Qt",
};
public :
QtApplication(int &argc, char **argv);
int exec(); //overloadded exec from QApplication
};
class QtScreen
{
protected :
int m_x;
int m_y;
int m_width;
int m_height;
QtWindow *m_window;
bool m_bounds_restricted;
/* virtual char **getArgs(int *argc);
virtual void computeBounds();
virtual void createQtWindow();
virtual void windowShown();
*/
public :
QtScreen();
bool init();
/* void close();
void showWindow();
void setMouseCursor(int cursor);
void beep();
int width();
int height();
int dotsPerInch();
QtWindow *window();
int x();
int y();
*/
};
class QtScreenFactory
{
static QtScreen *theScreen;
public:
static QtScreen *getScreen();
};
QtWindow *m_window;
QtScreen *QtScreenFactory::theScreen = NULL;
QtApplication
::QtApplication(int &argc,
char **argv
) : QApplication(argc, argv
) {}
int
QtApplication::exec(void) {
printf("QApplication exec called\n");
printf("QApplication exec done\n");
}
QtWindow
::QtWindow(int flags,
const char *name,
QWidget *parent
) : QWidget(parent,
(Qt
::WindowFlags)flags
) {
setMouseTracking(true);
}
void
{
printf("paintEvent called\n");
#if 0
qp->setColor(c);
p.
setCompositionMode(QPainter::CompositionMode_SourceOver);
p.setPen(*qp);
p.setClipRect(0,0,800,600);
p.drawLine(30,135,790,135);
#endif
p.drawImage(pt, img);
}
int main(int argc, char **argv)
{
printf("argc %d, argv %s\n",argc, *argv);
QtScreen *screen = QtScreenFactory::getScreen();
// img = new QImage(800,600,QImage::Format_ARGB32);
}
QtScreen *
QtScreenFactory::getScreen() {
if ( QtScreenFactory::theScreen == NULL ) {
QtScreenFactory::theScreen = new QtScreen();
if(QtScreenFactory::theScreen != NULL) {
QtScreenFactory::theScreen->init();
}
}
return QtScreenFactory::theScreen;
}
QtScreen::QtScreen()
{
}
void getQtColorModel()
{
int depth = 0;
int amask=0,rmask=0,gmask=0,bmask=0;
depth = d->depth();
printf ("Depth = %d\n", depth);
switch(depth) {
case 32:
amask = 0xff000000;
case 24:
rmask = 0x00ff0000;
gmask = 0x0000ff00;
bmask = 0x000000ff;
break;
}
}
void Qtexec()
{
qtApp->exec();
}
bool
QtScreen::init()
{
pthread_t tid;
int m_x = 0,m_y=0,m_width=800,m_height=600;
int argc = 1;
char *argv[3] = {"a.out", "-qws", NULL};
new QtApplication(argc, argv);
m_window = new QtWindow(Qt::FramelessWindowHint|Qt::Window);
qtApp->setActiveWindow(m_window);
printf("exec called\n");
m_window->show();
getQtColorModel();
#if 1
pthread_create(&tid, NULL, (void *(*)(void *))threadfunc, NULL);
#endif
Qtexec();
}
void threadfunc(void *arg)
{
printf("threadfunc called\n");
AWT_drawline(30,135,790,135);
}
void
AWT_drawline(int x1, int y1, int x2, int y2)
{
#if 0
p.
setCompositionMode(QPainter::CompositionMode_SourceOver);
p.setPen(*qp);
p.setClipRect(0,0,800,600);
p.drawLine(30,135,790,135);
#endif
p.
setCompositionMode(QPainter::CompositionMode_SourceOver);
qp->setColor(c);
p.setPen(*qp);
p.setClipRect(0,0,800,600);
p.drawLine(x1, y1, x2, y2);
m_window->update(0,0,800,600);
}
#include <pthread.h>
#include <Qt>
#include <QtCore>
#include <QtGui>
#include <QPainter>
#include <QWidget>
#include <QImage>
class QPen;
class QBrush;
class QImage;
#define qtApp ((QtApplication *)qApp)
void threadfunc(void *arg);
void AWT_drawline(int x1, int y1, int x2, int y2);
void getQtColorModel();
void Qtexec();
QImage img(800,600,QImage::Format_ARGB32);
class QtWindow : public QWidget
{
QBitmap transMask;
public:
QtWindow(int flags,
const char *name = "Sun AWT/Qt",
QWidget *parent = NULL) ;
virtual void paintEvent(QPaintEvent *);
};
class QtApplication : public QApplication {
public :
QtApplication(int &argc, char **argv);
int exec(); //overloadded exec from QApplication
};
class QtScreen
{
protected :
int m_x;
int m_y;
int m_width;
int m_height;
QtWindow *m_window;
bool m_bounds_restricted;
/* virtual char **getArgs(int *argc);
virtual void computeBounds();
virtual void createQtWindow();
virtual void windowShown();
*/
public :
QtScreen();
bool init();
/* void close();
void showWindow();
void setMouseCursor(int cursor);
void beep();
int width();
int height();
int dotsPerInch();
QtWindow *window();
int x();
int y();
*/
};
class QtScreenFactory
{
static QtScreen *theScreen;
public:
static QtScreen *getScreen();
};
QtWindow *m_window;
QtScreen *QtScreenFactory::theScreen = NULL;
QtApplication::QtApplication(int &argc, char **argv) : QApplication(argc, argv) {
}
int
QtApplication::exec(void) {
printf("QApplication exec called\n");
QApplication::exec();
printf("QApplication exec done\n");
}
QtWindow::QtWindow(int flags, const char *name, QWidget *parent) :
QWidget(parent, (Qt::WindowFlags)flags)
{
setMouseTracking(true);
}
void
QtWindow::paintEvent(QPaintEvent *event)
{
printf("paintEvent called\n");
#if 0
QPen *qp = new QPen();
QColor c(0xffff0000);
qp->setColor(c);
QBrush *qb = new QBrush();
QPainter p(this);
p.setCompositionMode(QPainter::CompositionMode_SourceOver);
p.setPen(*qp);
p.setClipRect(0,0,800,600);
p.drawLine(30,135,790,135);
#endif
QPainter p(m_window);
QPoint pt(0,0);
p.drawImage(pt, img);
}
int main(int argc, char **argv)
{
printf("argc %d, argv %s\n",argc, *argv);
QtScreen *screen = QtScreenFactory::getScreen();
// img = new QImage(800,600,QImage::Format_ARGB32);
}
QtScreen *
QtScreenFactory::getScreen() {
if ( QtScreenFactory::theScreen == NULL ) {
QtScreenFactory::theScreen = new QtScreen();
if(QtScreenFactory::theScreen != NULL) {
QtScreenFactory::theScreen->init();
}
}
return QtScreenFactory::theScreen;
}
QtScreen::QtScreen()
{
}
void getQtColorModel()
{
int depth = 0;
int amask=0,rmask=0,gmask=0,bmask=0;
QWidget *d = QApplication::desktop();
depth = d->depth();
printf ("Depth = %d\n", depth);
switch(depth) {
case 32:
amask = 0xff000000;
case 24:
rmask = 0x00ff0000;
gmask = 0x0000ff00;
bmask = 0x000000ff;
break;
}
}
void Qtexec()
{
qtApp->exec();
}
bool
QtScreen::init()
{
pthread_t tid;
int m_x = 0,m_y=0,m_width=800,m_height=600;
int argc = 1;
char *argv[3] = {"a.out", "-qws", NULL};
new QtApplication(argc, argv);
m_window = new QtWindow(Qt::FramelessWindowHint|Qt::Window);
QBitmap bitmap(m_width, m_height);
qtApp->setActiveWindow(m_window);
QPaintDevice *qpd = m_window;
printf("exec called\n");
m_window->show();
getQtColorModel();
#if 1
pthread_create(&tid, NULL, (void *(*)(void *))threadfunc, NULL);
#endif
Qtexec();
}
void threadfunc(void *arg)
{
printf("threadfunc called\n");
AWT_drawline(30,135,790,135);
}
void
AWT_drawline(int x1, int y1, int x2, int y2)
{
#if 0
QPen *qp = new QPen();
QBrush *qb = new QBrush();
QPainter p(qpd);
p.setCompositionMode(QPainter::CompositionMode_SourceOver);
p.setPen(*qp);
p.setClipRect(0,0,800,600);
p.drawLine(30,135,790,135);
#endif
QPainter p(&img);
p.setCompositionMode(QPainter::CompositionMode_SourceOver);
QPen *qp = new QPen();
QColor c(0xffff0000);
qp->setColor(c);
QBrush *qb = new QBrush();
p.setPen(*qp);
p.setClipRect(0,0,800,600);
p.drawLine(x1, y1, x2, y2);
m_window->update(0,0,800,600);
}
To copy to clipboard, switch view to plain text mode
Bookmarks