You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
117 lines
3.0 KiB
117 lines
3.0 KiB
3 years ago
|
//
|
||
|
// C++ Implementation: komposegldesktopwidget
|
||
|
//
|
||
|
// Description:
|
||
|
//
|
||
|
//
|
||
|
// Author: Hans Oischinger <oisch@sourceforge.net>, (C) 2004
|
||
|
//
|
||
|
// Copyright: See COPYING file that comes with this distribution
|
||
|
//
|
||
|
//
|
||
|
#include "komposegldesktopwidget.h"
|
||
|
|
||
|
#include "komposetask.h"
|
||
|
#include "komposegltaskwidget.h"
|
||
|
#include "komposetaskmanager.h"
|
||
|
|
||
3 years ago
|
#include <tqdesktopwidget.h>
|
||
|
#include <tqobjectlist.h>
|
||
3 years ago
|
#include <kdebug.h>
|
||
|
|
||
|
#include <GL/gl.h>
|
||
|
|
||
3 years ago
|
KomposeGLDesktopWidget::KomposeGLDesktopWidget(int desktop, TQObject *parent, const char *name)
|
||
3 years ago
|
: KomposeGLWidget( parent ),
|
||
|
deskNum( desktop )
|
||
|
{
|
||
|
// Retrieve geometry
|
||
3 years ago
|
TQDesktopWidget *deskwidget = new TQDesktopWidget();
|
||
3 years ago
|
deskRect = deskwidget->availableGeometry();
|
||
|
delete deskwidget;
|
||
|
|
||
|
createTaskWidgets();
|
||
|
|
||
|
//connect( KomposeTaskManager::instance(), SIGNAL( newTask( KomposeTask* ) ), this, SLOT( createTaskWidget( KomposeTask* ) ) );
|
||
|
}
|
||
|
|
||
|
|
||
|
KomposeGLDesktopWidget::~KomposeGLDesktopWidget()
|
||
|
{}
|
||
|
|
||
|
void KomposeGLDesktopWidget::createTaskWidgets()
|
||
|
{
|
||
|
TaskList tl = KomposeTaskManager::instance()->getTasks();
|
||
3 years ago
|
tqDebug("KomposeGLDesktopWidget::createTaskWidgets() on %d tasks", tl.count());
|
||
|
TQPtrListIterator<KomposeTask> it( tl );
|
||
3 years ago
|
KomposeTask *task;
|
||
|
while ( (task = it.current()) != 0 )
|
||
|
{
|
||
|
++it;
|
||
3 years ago
|
TQ_CHECK_PTR(task);
|
||
3 years ago
|
createTaskWidget( task );
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
void KomposeGLDesktopWidget::createTaskWidget( KomposeTask* task )
|
||
|
{
|
||
|
if (deskNum == task->onDesktop()-1 )
|
||
|
{
|
||
3 years ago
|
tqDebug("KomposeGLDesktopWidget::createTaskWidget()" );
|
||
3 years ago
|
KomposeGLTaskWidget *taskwidget = new KomposeGLTaskWidget( task, this, 0, "" );
|
||
|
}
|
||
|
}
|
||
|
|
||
|
int KomposeGLDesktopWidget::getHeightForWidth( int w ) const
|
||
|
{
|
||
3 years ago
|
tqDebug("KomposeGLDesktopWidget::getHeightForWidth()");
|
||
3 years ago
|
return ((double)w / (double)deskRect.width()) * deskRect.height();
|
||
|
}
|
||
|
|
||
|
int KomposeGLDesktopWidget::getWidthForHeight( int h ) const
|
||
|
{
|
||
3 years ago
|
tqDebug("KomposeGLDesktopWidget::getWidthForHeight()");
|
||
3 years ago
|
return ((double)h / (double)deskRect.height()) * deskRect.width();
|
||
|
}
|
||
|
|
||
|
double KomposeGLDesktopWidget::getAspectRatio()
|
||
|
{
|
||
3 years ago
|
tqDebug("KomposeGLDesktopWidget::getAspectRatio()");
|
||
3 years ago
|
return (double)deskRect.width() / (double)deskRect.height();
|
||
|
}
|
||
|
|
||
|
|
||
|
void KomposeGLDesktopWidget::draw()
|
||
|
{
|
||
|
KomposeGLWidget::draw();
|
||
3 years ago
|
tqDebug("KomposeGLDesktopWidget::draw() - %d,%d %dx%d", getRect().x(), getRect().y(), getRect().width(), getRect().height());
|
||
3 years ago
|
glColor3f(0.0f, 0.0f, 1.0f);
|
||
|
|
||
|
glBegin( GL_QUADS );
|
||
|
glVertex2i( getRect().x() + getRect().width(), getRect().y() );
|
||
|
glVertex2i( getRect().x(), getRect().y() );
|
||
|
glVertex2i( getRect().x(), getRect().y() + getRect().height() );
|
||
|
glVertex2i( getRect().x() + getRect().width(), getRect().y() + getRect().height() );
|
||
|
glEnd();
|
||
|
|
||
|
// Draw Task Widgets
|
||
3 years ago
|
TQPtrListIterator<KomposeGLWidget> it( list );
|
||
3 years ago
|
|
||
|
// Check or empty list
|
||
|
if (it.count() == 0)
|
||
|
{
|
||
3 years ago
|
tqDebug("KomposeGLDesktopWidget::draw() - empty list... skipping!");
|
||
3 years ago
|
return;
|
||
|
}
|
||
|
|
||
|
KomposeGLWidget *widget;
|
||
|
while ( (widget = (KomposeGLWidget*)it.current()) != 0 )
|
||
|
{
|
||
|
++it;
|
||
|
widget->draw();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#include "komposegldesktopwidget.moc"
|