Back to index

kdeartwork  4.3.2
Classes | Defines | Functions
kvm.cpp File Reference
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <qcolor.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qslider.h>
#include <qpainter.h>
#include <qbitmap.h>
#include <kapplication.h>
#include <kconfig.h>
#include <klocale.h>
#include <kglobal.h>
#include <kmessagebox.h>
#include "kvm.h"
#include "vm.xpm"
#include "vm.xbm"
#include "kvm.moc"

Go to the source code of this file.

Classes

class  kVmSaverInterface

Defines

#define CHAR_HEIGHT   22

Functions

int main (int argc, char *argv[])
static void load_images (m_state *state)
static m_stateinit_pool (QWidget *w)
static void draw_pool (m_state *state)

Define Documentation

#define CHAR_HEIGHT   22

Definition at line 54 of file kvm.cpp.


Function Documentation

static void draw_pool ( m_state state) [static]

Definition at line 130 of file kvm.cpp.

{
  int x, y;
  struct tvm_process*       curr_thread;

  if( state->show_threads ) {
   curr_thread = state->pool->processes;
   while( curr_thread ) {
    state->modified[curr_thread->position] = 2;
    curr_thread = curr_thread->next;
   }
  }
  for (y = 0; y < state->grid_height; y++)
    for (x = 0; x < state->grid_width; x++) {
     int index = state->grid_width * y + x;
     if( state->modified[index] )
      {
        int op = state->pool->area[index];
        int pos_y;
        int pos_x = 0;
        switch( op ) {
         case VM_OP_STOP:
          pos_y = 14;
          break;

         case VM_OP_EXEC:
          pos_y = 15;
          break;

         case VM_OP_COPY:
          pos_y = 12;
          break;

         default:
          pos_y = op - VM_OP_PUSH;
          if( pos_y < 0 ) {
           pos_y = -pos_y;
           pos_x = 1;
          }
          break;
        }
        if( state->show_threads )
         if( state->modified[index] == 1 )
          pos_x += 2;
          QPainter p(state->w);
          p.setPen( Qt::green );
          p.setBrush( Qt::black );
          p.drawPixmap( state->grid_margin_x + x*state->char_width,
                         state->grid_margin_y + y*state->char_height,
                         state->images, pos_x*state->char_width,
                         pos_y*state->char_height,
                         state->char_width, state->char_height );
       --state->modified[index];
      }
    }
}

Here is the caller graph for this function:

static m_state* init_pool ( QWidget *  w) [static]

Definition at line 105 of file kvm.cpp.

{
  m_state *state = new m_state;
  state->w = w;

  load_images (state);

  state->char_width = state->image_width / 4;
  state->char_height = CHAR_HEIGHT;

  state->grid_width  = w->width()  / state->char_width;
  state->grid_height = w->height() / state->char_height;
  state->grid_margin_x = w->width()%state->char_width/2;
  state->grid_margin_y = w->height()%state->char_height/2;
  state->show_threads = 1;
  vm_init_pool( &(state->pool), state->grid_width*state->grid_height,
                THREAD_MAX_STACK_SIZE, MAX_THREADS_NUM );
   //vm_enable_reverse( state->pool, 1 );
   state->modified = new char[state->grid_height*state->grid_width];
   for( int x = 0; x < state->grid_width*state->grid_height; ++x )
    state->modified[x] = 1;
  return state;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void load_images ( m_state state) [static]

Definition at line 88 of file kvm.cpp.

{
  if ( QPixmap::defaultDepth() > 1 )
    {
      state->images = QPixmap( vm );
    }
  else
    {
      state->images = QBitmap::fromData( QSize(vm_width, vm_height), vm_bits );
    }
  state->image_width = state->images.width();
  state->image_height = state->images.height();
  state->nglyphs = state->image_height / CHAR_HEIGHT;
}

Here is the caller graph for this function:

int main ( int  argc,
char *  argv[] 
)

Definition at line 79 of file kvm.cpp.

{
    kVmSaverInterface kss;
    return kScreenSaverMain( argc, argv, kss );
}