/* * ItemColor_Draw. We don't draw the title, so return 0 if value is NULL */ int ItemColor_Draw( int column, void *value, LWRasterID raster, int x, int y, int w, int h, IMPGhostModes ghosting ) { // Figure out the color square's size int draw_x = x + 6; int draw_y = y + 3; int draw_w = w - 12; int draw_h = h - 6; int color; int text_color = (ghosting == IMPGHOST_DISABLED) ? RGB_( 80, 80, 80 ) : RGB_( 0, 0, 0 ); if( value == NULL ) return 0; if( draw_w > 40 ) draw_w = 40; if( raster == NULL ) return 40; color = *(int *)value; // Draw the square EmptyBox( raster, raster_funcs, draw_x, draw_y, draw_w, draw_h, 1, 1, RGB_( 80, 80, 80 ), RGB_( 200, 200, 200 ) ); raster_funcs->drawRGBBox( raster, ItemColors[ color ][ 0 ], ItemColors[ color ][ 1 ], ItemColors[ color ][ 2 ], draw_x+1, draw_y+1, draw_w-2, draw_h-2 ); // Draw the text if( (color >= 0) && (color < 15) ) raster_funcs->drawText( raster, (char *)item_color_list[ color ], text_color, draw_x + draw_w + 10, draw_y ); return 40; }
/* * Locked_Draw. * Draws both the cells and the column title */ int Locked_Draw( int column, void *value, LWRasterID raster, int x, int y, int w, int h, IMPGhostModes ghosting ) { int draw_x = x + (w/2) - (icon_width/2); int draw_y = y + 2; int prime_color = (ghosting == IMPGHOST_DISABLED) ? RGB_( 110, 110, 110 ) : RGB_( 80, 80, 80 ); int second_color = RGB_( 128, 128, 128 ); if( raster == NULL ) return icon_width + 4; if( value == NULL ) { DrawLWIcon( raster, raster_funcs, draw_x, draw_y, ICON_LOCK, RGB_( 0, 0, 0 ), second_color ); } else { int state = *(int *)value; if( state != 0 ) DrawLWIcon( raster, raster_funcs, draw_x, draw_y, ICON_LOCK, prime_color, second_color ); } return icon_width + 4; }
// 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 ); }
// 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 ); }
int Visibility_Draw( int column, void *value, LWRasterID raster, int x, int y, int w, int h, IMPGhostModes ghosting ) { int draw_w = w < 30 ? w : 30; int draw_x = x + 1 + (draw_w/2) - (icon_width/2); int draw_y = y + 2; int prime_color = (ghosting == IMPGHOST_DISABLED) ? RGB_( 110, 110, 110 ) : RGB_( 80, 80, 80 ); int second_color = RGB_( 128, 128, 128 ); if( raster == NULL ) return icon_width + 4; if( value == NULL ) { DrawLWIcon( raster, raster_funcs, draw_x, draw_y, ICON_VISIBILITY_EYE, RGB_( 0, 0, 0 ), second_color ); } else { int index = *(int *)value; if( index != 0 ) { int icon; switch( index ) { case 1: icon = ICON_BOUNDING_BOX; break; case 2: icon = ICON_POINTS_ONLY; break; case 3: icon = ICON_WIREFRAME; break; case 4: icon = ICON_FRONTFACE; break; case 5: icon = ICON_SOLID; break; case 6: icon = ICON_TEXTURED; break; default: icon = ICON_DOT; } DrawLWIcon( raster, raster_funcs, draw_x, draw_y, icon, prime_color, second_color ); } if( (index >= 0) && (index < 7) ) { int text_color = (ghosting == IMPGHOST_DISABLED) ? RGB_( 80, 80, 80 ) : RGB_( 0, 0, 0 ); raster_funcs->drawText( raster, (char *)item_vis_list[ index ], text_color, draw_x + icon_width + 10, draw_y ); } } return icon_width + 4; }
// 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 ); }