Exemple #1
0
static void devent( LWControl *ctl, void *data )
{
   LWPanelFuncs *panf;
   const LWDisplayMetrics *dmet;
   LWPanelID panel;
   LWValue
      ival = { LWT_INTEGER },
      ivecval = { LWT_VINT };
   int x, y, md[ 3 ];
   char a[ 32 ];


   /* panel, panf, dmet */

   panel = ( LWPanelID ) CON_PAN( ctl );
   panf = ( LWPanelFuncs * ) CON_PANFUN( ctl );
   dmet = panf->drawFuncs->dispMetrics();

   /* control dimensions */

   x = CON_HOTX( ctl );
   y = CON_HOTY( ctl );

   /* mouse drag coordinates */

   GETV_IVEC( ctl, md );
   sprintf( a, "%d %d %d", md[ 0 ], md[ 1 ], md[ 2 ] );
   panf->drawFuncs->drawBox( panel, COLOR_LT_YELLOW, x - 90, y, 80,
      dmet->textHeight );
   panf->drawFuncs->drawText( panel, a, COLOR_BLACK, x - 88, y );
}
Exemple #2
0
static void sevent( LWControl *ctl, void *data )
{
   LWPanelFuncs *panf;
   const LWDisplayMetrics *dmet;
   LWPanelID panel;
   LWValue
      ival = { LWT_INTEGER },
      ivecval = { LWT_VINT };
   int x, y, w, h, m;
   char a[ 32 ];


   /* panel, panf, dmet */

   panel = ( LWPanelID ) CON_PAN( ctl );
   panf = ( LWPanelFuncs * ) CON_PANFUN( ctl );
   dmet = panf->drawFuncs->dispMetrics();

   /* control dimensions */

   x = CON_HOTX( ctl );
   y = CON_HOTY( ctl );
   w = CON_HOTW( ctl );
   h = CON_HOTH( ctl );
   x += w;
   y += ( h - dmet->textHeight ) / 2;

   /* mouse drag coordinates */

   GET_INT( ctl, m );
   sprintf( a, "%d", m );
   panf->drawFuncs->drawBox( panel, COLOR_LT_YELLOW, x + 10, y, 40,
      dmet->textHeight );
   panf->drawFuncs->drawText( panel, a, COLOR_BLACK, x + 12, y );
}
Exemple #3
0
// DrawStatusLine():
//  Called to draw the Status Line.
void DrawStatusLine(LWControl *ctl, FreeKeyInterface *ui, DrMode mode) {
  CDrawFuncs *df = fk_int->panel_funcs->DrawFuncs;

  int cx = CON_HOTX( ctl );
  int cy = CON_HOTY( ctl );
  int cw = CON_HOTW( ctl );
  int ch = CON_HOTH( ctl );

  if( fk_int->processing ) {
    // Progress Bar Drawing
    // Draw the bar
    df->DrawRGBBox( fk_int->main_panel, 0, 60, 150, cx+1, cy+1,
                    (int)( (cw-2) * ((double)fk_int->progress_cur / (double)fk_int->progress_total) ), ch-2 );

    // Clear the area outside the bar
    df->DrawRGBBox( fk_int->main_panel, 132, 130, 132, cx + (cw-2) * ((double)fk_int->progress_cur / (double)fk_int->progress_total) + 1, cy+1,
                    cw - (int)( ((double)(cw-2) * ((double)fk_int->progress_cur / (double)fk_int->progress_total)) - 2), ch-2 );

    // Write the name of the current object on the bar
    df->WriteText( fk_int->main_panel, fk_int->status_text, COLOR_WHITE, cx+4, cy );
  } else {
    // Standard Message Drawing
    if( fk_int->status_mode == STATUSMODE_ERROR ) {
      df->DrawRGBBox( fk_int->main_panel, 175, 0, 0, cx+1, cy+1, cw-2, ch-2 );
      df->WriteText( fk_int->main_panel, fk_int->status_text, COLOR_LT_YELLOW, cx+4, cy );
    } else if( fk_int->status_mode == STATUSMODE_NOTICE ) {
      df->DrawRGBBox( fk_int->main_panel, 200, 185, 0, cx+1, cy+1, cw-2, ch-2 );
      df->WriteText( fk_int->main_panel, fk_int->status_text, COLOR_BLACK, cx+4, cy );
    } else {  // Default to Info mode
      df->DrawRGBBox( fk_int->main_panel, 132, 130, 132, cx+1, cy+1, cw-2, ch-2 );
      df->WriteText( fk_int->main_panel, fk_int->status_text, COLOR_BLACK, cx+4, cy );
    }
  }
}
Exemple #4
0
static void draw_canvas( LWControl *ctl, FrameBuf *fbuf, DrMode mode )
{
   int x, y;

   x = CON_HOTX( ctl );
   y = CON_HOTY( ctl );
   rasf->blitPanel( fbuf->ras, 0, 0, fbuf->panel, x, y, fbuf->w, fbuf->h );
}
Exemple #5
0
void clrtext( int r1, int c1, int r2, int c2 )
{
   int x, y, w, h;

   x = DX + CON_HOTX( ctl[ 0 ] ) + TXWIDTH * ( c1 - 1 );
   y = DY + CON_HOTY( ctl[ 0 ] ) + TXHEIGHT * ( r1 - 1 );
   w = TXWIDTH * ( c2 - c1 + 1 );
   h = TXHEIGHT * ( r2 - r1 + 1 );

   panf->drawFuncs->drawBox( panel, COLOR_BG, x, y, w, h );
}
Exemple #6
0
void outtext( int row, int col, char *a )
{
   int x, y, i, len, c;

   if ( col <= 10 )
      c = 0;
   else if ( col <= 60 )
      c = 1;
   else
      c = 2;

   x = DX + CON_HOTX( ctl[ 0 ] ) + TXWIDTH * ( col - 1 );
   y = DY + CON_HOTY( ctl[ 0 ] ) + TXHEIGHT * ( row - 1 );
   len = strlen( a );

   for ( i = 0; i < len; i++, x += TXWIDTH )
      draw_char( a[ i ], x, y, cras[ c ], rasf, panel );
}
Exemple #7
0
// OnItemMultiScroll():
//  Called to handle the custom scroll bar under the lister
void OnItemMultiScroll( LWControl *ctl, int mx, fk_mousestate mouse_state ) {
  static last_clicked = CLICKED_NONE;
  static down_pos     = 0;
  static item_pos     = 0;

  // Mouse Released; Reset
  if( mouse_state == MSTATE_UP ) {
    SET_STR( fk_int->select_item_name, "MS:  Mouse Released", strlen( "MS:  Mouse Released" ) );
    last_clicked = CLICKED_NONE;
    REDRAW_CON( fk_int->item_multiscroll );
    return;
  }

  // Mouse was just clicked; see what was clicked
  if( mouse_state == MSTATE_DOWN ) {
    down_pos = mx;
    mx -= CON_HOTX( ctl );

    // Test the Divider
    int div_near = mx > fk_int->ms_divider ? mx-fk_int->ms_divider: fk_int->ms_divider-mx;
    if( div_near < 6 ) {
      last_clicked = CLICKED_DIVIDER;
      item_pos = fk_int->ms_divider;

      SET_STR( fk_int->select_item_name, "MS:  Clicked Divider", strlen( "MS:  Clicked Divider" ) );
    }

    return;
  }

  // Mouse Moved:  Change some value
  if( mouse_state == MSTATE_MOVING ) {
    if( last_clicked == CLICKED_DIVIDER )
      fk_int->ms_divider = mx;
//      fk_int->ms_divider = down_pos - item_pos + mx - item_pos;

    char buffer[ 64 ];
    sprintf( buffer, "MS:  Moved Divider to %d", fk_int->ms_divider );
    SET_STR( fk_int->select_item_name, buffer, strlen( buffer ) );

    REDRAW_CON( ctl );
  }
}
Exemple #8
0
// DrawLWListerHSlider():
void DrawLWListerHSlider( LWControl *ctl, LWLister *lister, DrMode mode ) {
  CDrawFuncs df( lister->GetPanelFuncs()->drawFuncs );
  LWRasterFuncs *rf = lister->GetRasterFuncs();

  // Get some sizes
  int cx = CON_HOTX( lister->GetHSlider() );
  int cy = CON_HOTY( lister->GetHSlider() );
  int cw = CON_HOTW( lister->GetHSlider() );
  int ch = CON_HOTH( lister->GetHSlider() );

  // Figure out where the slider should be drawn
  double slider_start  = 0.0;
  double slider_end    = 1.0;

  lister->GetHSliderKnobExtents( slider_start, slider_end );
  double slider_center = slider_start + (slider_end - slider_start)/2;

  // Draw the trough and knob
  double here;
  for( int i=0; i < cw; i++ ) {
    here = ((double)i/(double)cw);
    if( (here < slider_start) || (here > slider_end) )
      rf->blitPanel( lister->GetHSliderRasterTrough(), 0, 0, lister->GetPanel(), cx+i, cy, 1, 15 );
    else
      rf->blitPanel( lister->GetHSliderRasterKnob(),   0, 0, lister->GetPanel(), cx+i, cy, 1, 15 );
  }

  // Draw ticks on the knob
  int tick_start = (int)(slider_center * (double)cw) - 8;

  for( i=0; i < 4; i++ ) {
    df.DrawLine( lister->GetPanel(), RGB_(108, 120, 108), cx + tick_start,   cy+3, cx+tick_start,   cy+12 );
    df.DrawLine( lister->GetPanel(), RGB_(204, 216, 204), cx + tick_start+1, cy+3, cx+tick_start+1, cy+12 );
    tick_start += 5;
  }

  // Draw the border
  PanelDraw::EmptyBox( lister->GetPanel(), &df, cx-1, cy-1, cw+2, ch+2, 1, 1, 80, 80, 80,  80, 80, 80 );
}
Exemple #9
0
// DrawMSZoom():
//  Draws the lower scroll bar in the MultiScroll
void DrawMSZoom() {
  CDrawFuncs *df = fk_int->panel_funcs->DrawFuncs;

  int cx = CON_HOTX( fk_int->item_multiscroll );
  int cy = CON_HOTY( fk_int->item_multiscroll );
  int ch = CON_HOTH( fk_int->item_multiscroll );

  // Zoom Out
  PanelDraw::Button( fk_int->main_panel, df, cx+fk_int->ms_divider-25, cy, 20, ch, 1, 1,
                     LW_BUTTON_COLOR_PURPLE );
  int bx = cx+fk_int->ms_divider-25;
  PanelDraw::DrawArrow( fk_int->main_panel, df, bx+10, cy+(ch/2),
                        PanelDraw::arrow_toward_vert, PanelDraw::arrow_two_edges );

  // Zoom Slider
  PanelDraw::Button( fk_int->main_panel, df, cx+fk_int->ms_divider-105, cy, 80, ch, 1, 1,
                     LW_BUTTON_COLOR_GREEN );
  bx = cx+fk_int->ms_divider-105;

  df->DrawRGBBox( fk_int->main_panel,  90, 105,  90, bx+8, cy+3, 64, 1 );
  df->DrawRGBBox( fk_int->main_panel,  30,  60,  30, bx+8, cy+4, 64, 1 );
  df->DrawRGBBox( fk_int->main_panel, 222, 235, 222, bx+8, cy+5, 64, 1 );

  PanelDraw::DrawArrow( fk_int->main_panel, df, bx+70 - (int)( fk_int->ms_zoom * 60.0 ),
                        cy+(ch/2)+1, PanelDraw::arrow_up, PanelDraw::arrow_empty );

  // Zoom In
  PanelDraw::Button( fk_int->main_panel, df, cx+fk_int->ms_divider-125, cy, 20, ch, 1, 1,
                     LW_BUTTON_COLOR_PURPLE );
  bx = cx+fk_int->ms_divider-125;
  PanelDraw::DrawArrow( fk_int->main_panel, df, bx+10, cy+(ch/2),
                        PanelDraw::arrow_away_vert, PanelDraw::arrow_two_edges );

  // Zoom Factor Text
  char zoom_text[20];
  sprintf( zoom_text, "%g%%", fk_int->ms_zoom * 100.0 );
  df->WriteText( fk_int->main_panel, zoom_text, COLOR_LT_YELLOW, cx+3, cy );
}
Exemple #10
0
// WPopdown_ControlDraw():
void WPopdown_ControlDraw(  LWControl *con, void *data, DrMode mode ) {
  PanelControls_WPopdown *popdown = (PanelControls_WPopdown *)data;

  int x = CON_HOTX( popdown->control ) - 1;
  int y = CON_HOTY( popdown->control ) - 1;
  int w = CON_HOTW( popdown->control ) + 2;
  int h = CON_HOTH( popdown->control ) + 2;

  LWRasterID raster = popdown->raster_funcs->create( w, h, 0 );

  popdown->control->get( popdown->control, CTL_FLAGS, &ival );

  const char *title = (popdown->title == NULL) ? "(unknown)" : popdown->title;

  if( mode == DR_ERASE ) {
    if( ival.intv.value != CTLF_INVISIBLE )
      popdown->raster_funcs->drawBox( raster, LWP_BG, 0, 0, w, h );

  } else {
    RasterDraw::Button( raster, popdown->raster_funcs, 0, 0, w, h,  184, 196, 184,  0 );

    if( ival.intv.value == CTLF_DISABLE ) {    // Ghosted
      RasterDraw::DrawArrow( raster, popdown->raster_funcs, w - 9, h/2, RasterDraw::arrow_popup, RasterDraw::arrow_solid, RGB_( 204, 216, 204 ) );
      popdown->raster_funcs->drawText( raster, (char *)title, RGB_( 204, 216, 204 ), 6, 4 );

      RasterDraw::DrawArrow( raster, popdown->raster_funcs, w - 12, h/2 - 1, RasterDraw::arrow_popup, RasterDraw::arrow_solid, RGB_( 108, 120, 108 ) );
      popdown->raster_funcs->drawText( raster, (char *)title, RGB_( 108, 120, 108 ), 5, 3 );

    } else {                                   // Normal
      RasterDraw::DrawArrow( raster, popdown->raster_funcs, w - 12, h/2 - 1, RasterDraw::arrow_popup, RasterDraw::arrow_solid, RGB_( 0, 0, 0 ) );
      popdown->raster_funcs->drawText( raster, (char *)title, RGB_( 0, 0, 0 ), 5, 3 );
    }
  }

  popdown->raster_funcs->blitPanel( raster, 0, 0, popdown->panel, x, y, w, h );
  popdown->raster_funcs->destroy( raster );
}
Exemple #11
0
static void ctl_draw( LWControl *ectl, void *edata, DrMode mode )
{
   int x, y, w, h, dx, dy, npts, npols;
   char buf[ 24 ];

   elcount( &npts, &npols );

   x = CON_HOTX( ectl );
   y = CON_HOTY( ectl );
   w = CON_HOTW( ectl );
   h = CON_HOTH( ectl );

   panf->drawFuncs->drawBox( panel, LWP_INFO_BG, x, y, w, h );

   dy = ( h - 2 * dmet->textHeight ) / 3;
   dx = w / 2 - panf->drawFuncs->textWidth( panel, "Points:" );
   sprintf( buf, "Points: %d", npts );
   panf->drawFuncs->drawText( panel, buf, LWP_INFO_IMG, x + dx, y + dy );

   dy += dy + dmet->textHeight;
   dx = w / 2 - panf->drawFuncs->textWidth( panel, "Polygons:" );
   sprintf( buf, "Polygons: %d", npols );
   panf->drawFuncs->drawText( panel, buf, LWP_INFO_IMG, x + dx, y + dy );
}
Exemple #12
0
static int print_ui( char *outname, int *range, int *mode, int *cols,
   char *comment )
{
   char *rlist[] = { "Current Page", "Entire File", NULL };
   char *mlist[] = { "Write", "Append", NULL };
   char *tlist[] = { " ", NULL };
   LWPanelID panel;
   LWControl *ctl[ 8 ];
   int i, x, y, dy, ok;

   if( !( panel = PAN_CREATE( panf, "Print to File" )))
      return 0;

   ctl[ 0 ] = FILE_CTL( panf, panel, "File", 40 );
   ctl[ 1 ] = HCHOICE_CTL( panf, panel, "Range", rlist );
   ctl[ 2 ] = HCHOICE_CTL( panf, panel, "Mode", mlist );
   ctl[ 3 ] = TEXT_CTL( panf, panel, "Columns", tlist );
   ctl[ 4 ] = BOOLBUTTON_CTL( panf, panel, "Position" );
   ctl[ 5 ] = BOOLBUTTON_CTL( panf, panel, "Buffer" );
   ctl[ 6 ] = BOOLBUTTON_CTL( panf, panel, "Printable" );
   ctl[ 7 ] = STR_CTL( panf, panel, "Comment", 40 );

   for ( i = 0; i < 4; i++ ) {
      ival.intv.value = 100 - CON_LW( ctl[ i ] );
      ctl[ i ]->set( ctl[ i ], CTL_X, &ival );
   }

   x = CON_HOTX( ctl[ 2 ] );
   y = CON_Y( ctl[ 2 ] );
   dy = y - CON_Y( ctl[ 1 ] );
   y += dy;

   MOVE_CON( ctl[ 4 ], x, y );
   x += CON_W( ctl[ 4 ] );
   MOVE_CON( ctl[ 5 ], x, y );
   x += CON_W( ctl[ 5 ] );
   MOVE_CON( ctl[ 6 ], x, y );
   x = 100 - CON_LW( ctl[ 7 ] );
   y += dy;
   MOVE_CON( ctl[ 7 ], x, y );

   PAN_SETH( panf, panel, y + dy );

   SET_STR( ctl[ 0 ], outname, 256 );
   SET_INT( ctl[ 1 ], *range );
   SET_INT( ctl[ 2 ], *mode );
   SET_INT( ctl[ 4 ], ( *cols & 1 ));
   SET_INT( ctl[ 5 ], ( *cols & 2 ));
   SET_INT( ctl[ 6 ], ( *cols & 4 ));
   SET_STR( ctl[ 7 ], comment, 256 );

   ok = panf->open( panel, PANF_BLOCKING | PANF_CANCEL );

   if ( ok ) {
      GET_STR( ctl[ 0 ], outname, 256 );
      GET_INT( ctl[ 1 ], *range );
      GET_INT( ctl[ 2 ], *mode );
      GET_INT( ctl[ 4 ], i );  if ( i ) *cols |= 1; else *cols &= ~1;
      GET_INT( ctl[ 5 ], i );  if ( i ) *cols |= 2; else *cols &= ~2;
      GET_INT( ctl[ 6 ], i );  if ( i ) *cols |= 4; else *cols &= ~4;
      GET_STR( ctl[ 7 ], comment, 256 );
   }

   PAN_KILL( panf, panel );

   return ok;
}
Exemple #13
0
static void drawcb_icon( LWControl *ectl, void *edata, DrMode mode )
{
   draw_icon( CON_HOTX( ectl ), CON_HOTY( ectl ), rasf, panel );
}
Exemple #14
0
// Handle():
bool LWLister::Handle( int flags, int x, int y ) {
  static bool   was_down = false;
  static int    down_x, down_y;
  static int    active_control = -1;
  static bool   do_more;
  static bool   was_dragging;
  static int    item_count;
  static int    previous_first_visible_item;
  static int    most_recent_first_visible_item;
  static int    previous_leftmost_visible_pixel;
  static int    most_recent_leftmost_visible_pixel;

  #ifdef _DEBUG
    static bool clear_log = true;
    ofstream out( "i:\\mousetest.txt", (clear_log ? 0 : ios::app) );
    clear_log = false;

    out << "X/Y: " << x << "/" << y << "    " << ((flags & MOUSE_DOWN) ? "Mouse Down" : "Mouse Up" ) << endl;
  #endif

  // See if the mouse has just been clicked and find out which control we're in
  if( flags & MOUSE_DOWN ) {
    if( was_down == false ) {
      down_x = x;
      down_y = y;
      was_down = true;
      do_more  = true;
      was_dragging = false;
      item_count = count( user_data );
      previous_first_visible_item           = first_visible_item;
      most_recent_first_visible_item        = previous_first_visible_item;
      previous_leftmost_visible_pixel       = leftmost_visible_pixel;
      most_recent_leftmost_visible_pixel    = previous_leftmost_visible_pixel;

      // Test the Lister
      int cx = CON_HOTX( lister );
      int cy = CON_HOTY( lister );
      int cw = CON_HOTW( lister );
      int ch = CON_HOTH( lister );

      if( (x >= cx) && (y >=cy) && (x <= cx+cw) && (y <= cy+ch) ) {
        active_control = 0;

        #ifdef _DEBUG
          out << "- Mouse Down:  Lister" << endl;
        #endif
      } else {
        // Test the Vertical Scrollbar
        cx = CON_HOTX( vslider );
        cy = CON_HOTY( vslider );
        cw = CON_HOTW( vslider );
        ch = CON_HOTH( vslider );

        #ifdef _DEBUG
          out << "- Mouse Down:  Vertical Scrollbar" << endl;
        #endif

        if( (x >= cx) && (y >=cy) && (x <= cx+cw) && (y <= cy+ch) ) {
          active_control = 1;
        } else {
          // Test the Horizontal Scrollbar
          cx = CON_HOTX( hslider );
          cy = CON_HOTY( hslider );
          cw = CON_HOTW( hslider );
          ch = CON_HOTH( hslider );

          #ifdef _DEBUG
            out << "- Mouse Down:  Horizontal Scrollbar" << endl;
          #endif

          if( (x >= cx) && (y >=cy) && (x <= cx+cw) && (y <= cy+ch) ) {
            active_control = 2;
          } else {
            active_control = -1;
            return false;
          }
        }
      }
    }
  } else {
    #ifdef _DEBUG
      out << "- Mouse Up" << endl;
    #endif
    was_down = false;
  }

  // Mouse was clicked; decide how to handle it
  if( was_down && do_more ) {
    if( active_control == 0 ) {
      // Lister
      #ifdef _DEBUG
        out << "- Handle Lister" << endl;
      #endif
      return true;
    } else if( active_control == 1 ) {
      // Vertical Scrollbar
      double slider_start, slider_end;
      GetVSliderKnobExtents( slider_start, slider_end );

      // See if the slider fills the trough
      if( (slider_start <= 0.0) && (slider_end >= 1.0) ) {
        do_more = false;
        #ifdef _DEBUG
          out << "- Handle Vertical Scrollbar:  Slider Fills Trough" << endl;
        #endif
        return true;
      }

      // See if the user clicked in an empty part of the trough
      int ch = CON_HOTH( vslider );
      int cy = CON_HOTY( vslider );
      double click = (double)(y-cy)/(double)ch;

      int slider_size = (int)((slider_end - slider_start) * item_count);
      if( !was_dragging ) {
        int jump = 0;
        if( click < slider_start )
          jump = -1;
        else if( click > slider_end )
          jump = 1;

        if( jump != 0 ) {
          #ifdef _DEBUG
            out << "- Handle Vertical Scrollbar:  Jump " << jump << endl;
          #endif

          slider_size *= jump;
          first_visible_item += slider_size;

          if( first_visible_item < 0 )
            first_visible_item = 0;

          if( first_visible_item > (item_count - slider_size) )
            first_visible_item = item_count - slider_size;

          do_more = false;
          Redraw();
          return true;
        }
      }

      // Handle the user dragging the scrollbar
      was_dragging = true;
      double delta = (double)(y - down_y) / (double)ch;

      #ifdef _DEBUG
        out << "- Handle Vertical Scrollbar:  Drag -- Delta " << (y - down_y) << endl;
      #endif

      first_visible_item = previous_first_visible_item + (int)(delta * (double)item_count);

      if( first_visible_item < 0 )
        first_visible_item = 0;

      if( first_visible_item > (item_count - slider_size) )
        first_visible_item = item_count - slider_size;

      if( most_recent_first_visible_item != first_visible_item )  // This just keeps the UI from flickering when nothing has changed
        Redraw();

      most_recent_first_visible_item = first_visible_item;
      return true;
    } else if( active_control == 2 ) {
      // Horizontal Scrollbar
      double slider_start, slider_end;
      GetHSliderKnobExtents( slider_start, slider_end );

      // See if the slider fills the trough
      if( (slider_start <= 0.0) && (slider_end >= 1.0) ) {
        do_more = false;
        #ifdef _DEBUG
          out << "- Handle Horizontal Scrollbar: Slider Fills Trough" << endl;
        #endif
        return true;
      }

      // See if the user clicked in an empty part of the trough
      int cw = CON_HOTW( hslider );
      int cx = CON_HOTX( hslider );
      double click = (double)(x-cx)/(double)cw;

      int slider_size = (int)((slider_end - slider_start) * max_hscroll);
      if( !was_dragging ) {
        int jump = 0;
        if( click < slider_start )
          jump = -1;
        else if( click > slider_end )
          jump = 1;

        if( jump != 0 ) {
          #ifdef _DEBUG
            out << "- Handle Horizontal Scrollbar:  Jump " << jump << endl;
          #endif

          slider_size *= jump;
          leftmost_visible_pixel += slider_size;

          if( leftmost_visible_pixel < 0 )
            leftmost_visible_pixel = 0;

          if( leftmost_visible_pixel > (max_hscroll - slider_size) )
            leftmost_visible_pixel = max_hscroll - slider_size;

          do_more = false;
          Redraw();
          return true;
        }
      }

      // Handle the user dragging the scrollbar
      was_dragging = true;
      double delta = (double)(x - down_x) / (double)cw;

      leftmost_visible_pixel = previous_leftmost_visible_pixel + (int)(delta * (double)max_hscroll);

      #ifdef _DEBUG
        out << "- Handle Horizontal Scrollbar:  Drag -- Delta " << (x - down_x) << "; new LVP:  " << leftmost_visible_pixel << endl;
      #endif

      if( leftmost_visible_pixel < 0 )
        leftmost_visible_pixel = 0;

      if( leftmost_visible_pixel > (max_hscroll - slider_size) )
        leftmost_visible_pixel = max_hscroll - slider_size;

      if( most_recent_leftmost_visible_pixel != leftmost_visible_pixel )  // This just keeps the UI from flickering when nothing has changed
        Redraw();

      most_recent_leftmost_visible_pixel = leftmost_visible_pixel;
      return true;
    }
  }

  return false;
}
Exemple #15
0
// DrawLWLister():
void DrawLWLister( LWControl *ctl, LWLister *lister, DrMode mode ) {
  CDrawFuncs df( lister->GetPanelFuncs()->drawFuncs );
  LWRasterFuncs *rf = lister->GetRasterFuncs();

  // Get some sizes
  int cx = CON_HOTX( lister->GetLister() );
  int cy = CON_HOTY( lister->GetLister() );
  int cw = CON_HOTW( lister->GetLister() );
  int ch = CON_HOTH( lister->GetLister() );

  int line_height = df.DispMetrics()->textHeight + 2;

  int line, col;
  int col_x = 0;
  int count = (*lister->count)( lister->GetUserData() );
  int text_pad;

  for( line=0; ((line+1) * line_height) < ch; line++ ) {
    if( (lister->GetFirstVisibleItem() + (line - 1)) >= count )
      break;

    col_x = 0;
    for( col = 0; col < (int)lister->GetColumnWidths().NumElements(); col++ ) {
      text_pad = (col == 0) ? 5 : 2;

      // Compute the raster size and possible negative X offset
      int raster_col_x = col_x - lister->GetLeftmostVisiblePixel();
      int raster_col_w = lister->GetColumnWidths()[ col ];
      if( (raster_col_x + raster_col_w) < 0 ) {                                  // Ends before left edge
        // Set the next column's X position
        col_x += lister->GetColumnWidths()[ col ];
        continue;
      }

      if( raster_col_x > (lister->GetLeftmostVisiblePixel() + cw) )              // Starts after right edge
        break;

      if( raster_col_x < 0 )
        raster_col_w += raster_col_x;
      else
        raster_col_x = 0;

      // Compute the drawing position
      int draw_x = 0;
      if( col_x > lister->GetLeftmostVisiblePixel() )
        draw_x = col_x - lister->GetLeftmostVisiblePixel();

      // Adjust the raster width for the drawing position
      if( raster_col_w > (cw - draw_x) )
        raster_col_w = (cw - draw_x);

      // Create a raster area for this column of this line
      LWRasterID raster = rf->create( raster_col_w, line_height, 0 );

      if( line == 0 ) {
        // Header Line
        rf->drawRGBBox( raster, 112, 112, 112, 0, 0, raster_col_w, line_height );                            // Clear background

        const char * text = (*lister->name)( lister->GetUserData(), -1, col );
        if( text != NULL )
          rf->drawText( raster, (char *)text, COLOR_BLACK, raster_col_x + text_pad, 1 );                     // Text

        rf->drawLine( raster, COLOR_BLACK, 0, line_height-1, raster_col_w-1, line_height -1 );               // Draw row seperator line
        if( (col_x - lister->GetLeftmostVisiblePixel() + lister->GetColumnWidths()[ col ]) < cw )
          rf->drawLine( raster, COLOR_BLACK, raster_col_w-1, 0, raster_col_w-1, line_height - 1 );           // Draw column seperator Line
      } else {
        // Item Line
        rf->drawRGBBox( raster, 128, 128, 128, 0, 0, raster_col_w, line_height );                            // Clear background

        const char * text = (*lister->name)( lister->GetUserData(), lister->GetFirstVisibleItem() + (line - 1), col );
        if( text != NULL )
          rf->drawText( raster, (char *)text, COLOR_BLACK, raster_col_x + text_pad, 1 );                     // Text

        rf->drawLine( raster, RGB_(112, 112, 112), 0, line_height-1, raster_col_w-1, line_height -1 );       // Draw row seperator line
      }

      rf->blitPanel( raster, 0, 0, lister->GetPanel(), cx + draw_x, cy + (line * line_height), raster_col_w, line_height );
      rf->destroy( raster );

      // Set the next column's X position
      col_x += lister->GetColumnWidths()[ col ];

      // Exit the column loop if no more columns can fit
      if( col_x >= cw )
        break;
    }

    // Handle running out of columns
    int right_edge = col_x - lister->GetLeftmostVisiblePixel();
    if( right_edge < 0 )
      right_edge = 0;

    if( right_edge < cw ) {
      // Create a raster area for this column of this line
      LWRasterID raster = rf->create( cw - right_edge, line_height, 0 );

      if( line == 0 ) {
        // Header Line
        rf->drawRGBBox( raster, 112, 112, 112, 0, 0, cw - right_edge, line_height );                            // Clear background
        rf->drawLine( raster, COLOR_BLACK, 0, line_height-1, cw - right_edge -1, line_height -1 );              // Draw row seperator line
      } else {
        // Item Line
        rf->drawRGBBox( raster, 128, 128, 128, 0, 0, cw - right_edge, line_height );                            // Clear background
        rf->drawLine( raster, RGB_(112, 112, 112), 0, line_height-1, cw - right_edge -1, line_height -1 );      // Draw row seperator line
      }

      rf->blitPanel( raster, 0, 0, lister->GetPanel(), cx + right_edge, cy + (line * line_height), cw-right_edge, line_height );
      rf->destroy( raster );
    }
  }

  // Fill in the empty part of the list
  int remaining = (line * line_height);
  df.DrawRGBBox( lister->GetPanel(), 128, 128, 128, cx, cy+remaining, cw, ch-remaining );
}
Exemple #16
0
      sprintf( buffer, "Zin:  Factor:  %g", fk_int->ms_zoom );
      REDRAW_CON( ctl );
      REDRAW_CON( fk_int->item_list );

    // Test Zoom Out
    } else if( ( mx > (cx+fk_int->ms_divider - 125) ) &&
               ( mx < (cx+fk_int->ms_divider - 105) ) ) {
      last_clicked = CLICKED_ZOOM_OUT;

      fk_int->ms_zoom *= 2.0;
      if( fk_int->ms_zoom > 1.0 )
        fk_int->ms_zoom = 1.0;

      sprintf( buffer, "Zout:  Factor:  %g", fk_int->ms_zoom );
      REDRAW_CON( ctl );
      REDRAW_CON( fk_int->item_list );

    // No Item Clicked
*/

// Originally from OnMouse():
  int cx = CON_HOTX( fk_int->item_multiscroll );
  int cy = CON_HOTY( fk_int->item_multiscroll );
  int cw = CON_HOTW( fk_int->item_multiscroll );
  int ch = CON_HOTH( fk_int->item_multiscroll );

  // Test for Item MutliScroll
  if( (mx > cx) && (mx < (cx+cw)) && (my > cy) && (my < (cy+ch) ) )
    OnItemMultiScroll( fk_int->item_multiscroll, mx, state );