コード例 #1
0
ファイル: convolve.c プロジェクト: DimondTheCat/xray
static void create_controls( ConvolveInst *inst )
{
   const LWDisplayMetrics *dm;
   int x, y, dx, dy, w, i, pw, ph;


   /* create a control */

   ctl[ 0 ] = FLOAT_CTL( panf, panel, "" );

   /* find out how much vertical space the panel wants for drawing its
      own decorations */

   ph = PAN_GETH( panf, panel );
   ph -= CON_H( ctl[ 0 ] );

   /* create the rest of the controls */

   for ( i = 1; i < 9; i++ )
      ctl[ i ] = FLOAT_CTL( panf, panel, "" );

   ctl[ 9 ] = WPOPUP_CTL( panf, panel, "Presets", preset, 150 );

   /* position all of the controls */

   x  = CON_X( ctl[ 0 ] );
   y  = CON_Y( ctl[ 0 ] );
   dx = CON_HOTW( ctl[ 0 ] ) + 8;
   dy = CON_HOTH( ctl[ 0 ] ) + 4;

   for ( i = 1; i < 9; i++ )
      MOVE_CON( ctl[ i ], x + dx * ( i % 3 ), y + dy * ( i / 3 ));

   w = CON_W( ctl[ 9 ] );
   MOVE_CON( ctl[ 9 ], x + 3 * dx - w, y + 10 * dy / 3 );

   /* now that we know how much room the controls will take up, set the
      height of the panel and center it */

   ph += CON_Y( ctl[ 9 ] );
   ph += CON_HOTH( ctl[ 9 ] );
   PAN_SETH( panf, panel, ph - 6 );

   pw = PAN_GETW( panf, panel );
   dm = panf->drawFuncs->dispMetrics();
   MOVE_PAN( panf, panel, ( dm->width - pw ) / 2, ( dm->height - ph ) / 2 );

   /* initialize the controls */

   set_kernctl( inst );
   SET_INT( ctl[ 9 ], pindex );

   /* set the control event callbacks */

   CON_SETEVENT( ctl[ 9 ], handle_preset, inst );
}
コード例 #2
0
// DrawMainPanel() {
void DrawPanel( LWPanelID panel, void *data, DrMode mode) {
  CDrawFuncs df( rint->panel_funcs->drawFuncs );

  int ph = PAN_GETH( rint->panel_funcs, rint->panel );
  int pw = PAN_GETW( rint->panel_funcs, rint->panel );

  // Horizontal Dividers
  int y = CON_Y( rint->match_toggle );
  int h = CON_H( rint->match_toggle );
  PanelDraw::HorizontalDivider( rint->panel, &df, 0, y + h + 3, pw, 1 );

  y = CON_Y( rint->list );
  h = CON_H( rint->list );
  PanelDraw::HorizontalDivider( rint->panel, &df, 0, y + h + 3, pw, 1 );

  y = CON_Y( rint->enable );
  h = CON_H( rint->enable );
  PanelDraw::HorizontalDivider( rint->panel, &df, 0, y + h + 3, pw, 1 );
}
コード例 #3
0
// DrawProgressBar():
//  Called to draw the Progress Bar.
void DrawProgressBar(LWControl *ctl, FreeKeyInterface *ui, DrMode mode) {
  if( !processing_open )
    return;

  CDrawFuncs *df = fk_int->panel_funcs->DrawFuncs;

  int cx = CON_X( ctl );
  int cy = CON_Y( ctl );
  int cw = CON_W( ctl );
  int ch = CON_H( ctl );

  // Clear the control
  df->DrawBox( fk_int->process_panel, COLOR_BG, cx+1, cy+1, cw-2, ch-2 );

  // Draw the bar
  df->DrawRGBBox( fk_int->process_panel, 0, 200, 200, cx+1, cy+1,
                  (cw-2) * (fk_int->progress_cur / fk_int->progress_total), ch-2 );

  // Write the name of the current object on the bar
  df->WriteText( fk_int->process_panel, fk_int->progress_name, COLOR_WHITE, cx, cy+2 );
}
コード例 #4
0
// DrawMainPanel():
//  Draw details on the main panel (ie: dividers)
void SG_DrawMainPanel( LWPanelID panel_id, void *panel_user, DrMode panel_draw_mode ) {
  CDrawFuncs *df = simpg_int->panel_funcs->DrawFuncs;
  int ph = PAN_GETH( simpg_int->panel_funcs->orig_struct, simpg_int->main_panel );
  int pw = PAN_GETW( simpg_int->panel_funcs->orig_struct, simpg_int->main_panel );

  // Horizontal Dividers
  int y = CON_Y( simpg_int->output_scene );
  int h = CON_H( simpg_int->output_scene );
  PanelDraw::HorizontalDivider( simpg_int->main_panel, df, 0, y+h+2, pw, 1 );

/*
  y = CON_Y( simpg_int->render_filename );
  h = CON_H( simpg_int->render_filename );
  PanelDraw::HorizontalDivider( simpg_int->main_panel, df, 0, y+h+2, pw, 1 );

  y = CON_Y( simpg_int->lod_distance );
  h = CON_H( simpg_int->lod_distance );
  PanelDraw::HorizontalDivider( simpg_int->main_panel, df, 0, y+h+2, pw, 1 );
*/

  // Title Image
//  PanelDraw::DrawImage( simp_int->main_panel, df, logo, -25, 0 );
  logo.DrawInLWPanels( simpg_int->main_panel, df, -25, 0 );
}
コード例 #5
0
ファイル: window.c プロジェクト: DimondTheCat/xray
static void create_controls( void )
{
   static char *labtype[] = { "Byte", "Word", "Long", "Float", "Double", NULL };
   static char *labbyte[] = { "Intel", "Motorola", NULL };
   static char *labjump[] = { "Absolute", "Forward", "Backward", NULL };
   static char *labsrch[] = { "Text", "Text + Hex", "Current", NULL };
   int x, y, ph;


   /* create a control */

   ctl[ 1 ] = STR_CTL( panf, panel, "", 58 );

   /* find out how much vertical space the panel wants for drawing its
      own decorations */

   ph = PAN_GETH( panf, panel ) - CON_H( ctl[ 1 ] );

   /* create the rest of the controls */

   ctl[  0 ] = CANVAS_CTL( panf, panel, "", 78 * TXWIDTH + DX * 2,
      NROWS * TXHEIGHT + DY * 2 );

   ctl[  2 ] = STRRO_CTL( panf, panel, "", 21 );
   ctl[  3 ] = WPOPUP_CTL( panf, panel, "", labtype, 76 );
   ctl[  4 ] = BOOL_CTL( panf, panel, "Unsigned" );
   ctl[  5 ] = WPOPUP_CTL( panf, panel, "", labbyte, 76 );
   ctl[  6 ] = MINISLIDER_CTL( panf, panel, "", 4, 1, 16 );
   ctl[  7 ] = STR_CTL( panf, panel, "Jump", 12 );
   ctl[  8 ] = WBUTTON_CTL( panf, panel, "Search", 56 );
   ctl[  9 ] = STRRO_CTL( panf, panel, "Mod", 4 );
   ctl[ 10 ] = VSLIDER_CTL( panf, panel, "", NROWS * TXHEIGHT + DY * 2, 0, 1000 );
   ctl[ 11 ] = STRRO_CTL( panf, panel, "", 12 );
   ctl[ 12 ] = WPOPUP_CTL( panf, panel, "", labjump, 80 );
   ctl[ 13 ] = STR_CTL( panf, panel, "", 24 );
   ctl[ 14 ] = WPOPUP_CTL( panf, panel, "", labsrch, 80 );
   ctl[ 15 ] = CANVAS_CTL( panf, panel, "", 32, 32 );
   ctl[ 16 ] = WBUTTON_CTL( panf, panel, "New", 40 );

   /* position all of the controls */

   x = CON_X( ctl[ 0 ] );
   y = CON_Y( ctl[ 0 ] );
   y += CON_H( ctl[ 2 ] );
   MOVE_CON( ctl[ 0 ], x, y + 2 );

   y = CON_Y( ctl[ 0 ] );
   MOVE_CON( ctl[ 10 ], 79 * TXWIDTH + 10, y + 1 );

   y = CON_Y( ctl[ 1 ] ) + 2;
   x = CON_X( ctl[ 0 ] );
   MOVE_CON( ctl[ 16 ], x + DX, y );

   x += CON_W( ctl[ 16 ] );
   MOVE_CON( ctl[ 1 ], x, y );

   x = CON_X( ctl[ 1 ] );
   x += CON_W( ctl[ 1 ] );
   MOVE_CON( ctl[ 2 ], x, y );

   x = CON_X( ctl[ 10 ] );
   x += CON_W( ctl[ 10 ] );
   MOVE_CON( ctl[ 15 ], x - 32, y );

   y += CON_H( ctl[ 1 ] ) - 2;
   x = CON_X( ctl[ 0 ] );
   MOVE_CON( ctl[ 11 ], x - 3, y );

   x += CON_W( ctl[ 11 ] );
   MOVE_CON( ctl[ 9 ], x, y );

   x = CON_X( ctl[ 9 ] );
   x += CON_W( ctl[ 9 ] );
   MOVE_CON( ctl[ 6 ], x, y );

   x = CON_X( ctl[ 6 ] );
   x += CON_W( ctl[ 6 ] );
   MOVE_CON( ctl[ 5 ], x, y );

   x = CON_X( ctl[ 5 ] );
   x += CON_W( ctl[ 5 ] );
   MOVE_CON( ctl[ 3 ], x - 6, y );

   x = CON_X( ctl[ 3 ] );
   x += CON_W( ctl[ 3 ] );
   MOVE_CON( ctl[ 4 ], x, y );

   y = CON_Y( ctl[ 0 ] );
   y += CON_H( ctl[ 0 ] );
   x = CON_X( ctl[ 0 ] );
   MOVE_CON( ctl[ 7 ], x + DX, y );

   x = CON_X( ctl[ 7 ] );
   x += CON_W( ctl[ 7 ] );
   MOVE_CON( ctl[ 12 ], x - 4, y );

   x = CON_X( ctl[ 12 ] );
   x += CON_W( ctl[ 12 ] );
   MOVE_CON( ctl[ 8 ], x + 18, y );

   x = CON_X( ctl[ 8 ] );
   x += CON_W( ctl[ 8 ] );
   MOVE_CON( ctl[ 13 ], x - 4, y );

   x = CON_X( ctl[ 13 ] );
   x += CON_W( ctl[ 13 ] );
   MOVE_CON( ctl[ 14 ], x - 4, y );

   /* now that we know how much room the controls will take up, set the
      height of the panel */

   y = CON_Y( ctl[ 8 ] );
   y += CON_H( ctl[ 8 ] );
   PAN_SETH( panf, panel, y + ph - 6 );

   /* initialize the controls */

   SET_INT( ctl[ 3 ], datatype );
   SET_INT( ctl[ 4 ], unsign );
   SET_INT( ctl[ 5 ], byteorder );
   SET_INT( ctl[ 6 ], linesize );
   SET_STR( ctl[ 7 ], "0", 2 );
   SET_STR( ctl[ 9 ], "0", 2 );
   SET_INT( ctl[ 10 ], 0 );
   SET_STR( ctl[ 11 ], "0", 2 );
   SET_INT( ctl[ 12 ], 0 );
   SET_INT( ctl[ 14 ], 0 );

   /* set the control event callbacks */

   CON_SETEVENT( ctl[  1 ], handle_file, NULL );
   CON_SETEVENT( ctl[  3 ], handle_datatype, NULL );
   CON_SETEVENT( ctl[  4 ], handle_unsigned, NULL );
   CON_SETEVENT( ctl[  5 ], handle_byteorder, NULL );
   CON_SETEVENT( ctl[  6 ], handle_rowsize, NULL );
   CON_SETEVENT( ctl[  7 ], handle_jump, NULL );
   CON_SETEVENT( ctl[  8 ], handle_search, NULL );
   CON_SETEVENT( ctl[ 10 ], handle_scroll, NULL );
   CON_SETEVENT( ctl[ 13 ], handle_search, NULL );
   CON_SETEVENT( ctl[ 16 ], handle_new, NULL );

   /* set the control drawing callbacks */

   ival.ptr.ptr = drawcb_text;
   ctl[ 0 ]->set( ctl[ 0 ], CTL_USERDRAW, &ival );
   ival.ptr.ptr = drawcb_icon;
   ctl[ 15 ]->set( ctl[ 15 ], CTL_USERDRAW, &ival );
}
コード例 #6
0
// MakeMainPanel():
bool SimplifyGlobalInterface::MakeMainPanel() {
  // Set up Main Title String
  sprintf( main_title_bar, "Simplify Global Control V%d.%d from TM Productions",
           Simplify_Version, Simplify_Revision );

  // Create the Panel
  main_panel = panel_funcs->Create( main_title_bar );

  if( !main_panel ) {                    // Make sure the panel was created
    message->Error("Error creating main panel, aborting" );
    return false;
  }

  int x, y, w, h;
  try {
    // Source/Output Paths
    if( !( source_scene = FILE_CTL( panel_funcs->orig_struct, main_panel,
                                    "Source Scene", 70 ) ) )
      throw false;

    if( !( output_scene = FILE_CTL( panel_funcs->orig_struct, main_panel,
                                    "Output Scene", 70 ) ) )
      throw false;

    x = CON_X( source_scene );
    y = CON_X( source_scene );
    MOVE_CON( source_scene, x+16, y+70 );

    SET_STR( source_scene,  source_filename, strlen( source_filename ) );
    SET_STR( output_scene,  output_filename, strlen( output_filename ) );

    PanelTools::AlignLabels( source_scene, output_scene );

    // Instance Lister
    if( !( instance_listbox = LISTBOX_CTL( panel_funcs->orig_struct, main_panel,
                                           "Instance List", 363, 15,
                                           InstanceListerNames, InstanceListerCount)) )

    x = CON_X( instance_listbox );
    y = CON_Y( instance_listbox );
    MOVE_CON( instance_listbox, x+5, y );

    // Set the Panel Size
    y = CON_Y( instance_listbox );
    h = CON_H( instance_listbox );
    PAN_SETH( panel_funcs->orig_struct, main_panel, y + h + 30 );

    w = CON_X( output_scene );
    x = CON_W( output_scene );
    PAN_SETW( panel_funcs->orig_struct, main_panel, x + w );

    // Set the Draw Functions
    panel_funcs->Set( main_panel, PAN_USERDRAW, SG_DrawMainPanel );

    return true;
  } catch( bool a ) {
    if( !a ) {
      message->Error("Error creating interface controls; aborting" );
      return false;
    }
  }

  return true;
}
コード例 #7
0
// OnKeyDown():
//  Called on a key-down event.  This stores the state of
//   the modifiers and actually processes the keystrokes.
void OnKeyDown(LWPanelID panel, void *data, DualKey key) {
  if( key == DK_SHIFT )
    fk_int->shift_down = true;

  if( key == DK_CTRL )
    fk_int->ctrl_down  = true;

  if( key == DK_ALT ) {
    if( fk_int->draw_bbox && !fk_int->alt_down ) {
      fk_int->quickdraw_item_list = true;
      fk_int->RedrawItemList();
    }
    fk_int->alt_down  = true;
  }

  fk_int->last_key_down = key;

  // Used to move list up/down
  int list_height = CON_H( fk_int->item_list ) - 20;
  list_height = (list_height/ fk_int->dd.item_height);
  int max_top = fk_int->sorted_items.NumElements() - list_height;

  int value;
  static bool last_was_folded = false;  // Used to determine what to do on a Fold/Unfold All

  switch( fk_int->last_key_down ) {
    case -1:                            // No key deperessed, do nothing
      break;

    case DK_SC_UP:
      if( fk_int->shift_down ) {        // Jump to the top of the Item List
        fk->SetTopItem( 0 );
        SET_INT( fk_int->item_scroll, fk->GetTopItem() );
        fk_int->RedrawItemList();
      } else if( fk_int->alt_down && fk_int->ctrl_down ) {
        ;
      } else if( fk_int->alt_down ) {   // Scroll Group List Up (1 element)
        GET_INT( fk_int->group_list, value );
        if( value > 0 ) {
          SET_INT( fk_int->group_list, --value );
          OnGroupList( fk_int->group_list, fk_int );
        }
      } else if( fk_int->ctrl_down ) {
        fk->SetTopItem( fk->GetTopItem() - list_height );
        if( fk->GetTopItem() < 0 )
          fk->SetTopItem( 0 );
        SET_INT( fk_int->item_scroll, fk->GetTopItem() );
        fk_int->RedrawItemList();
      } else {                          // Scroll Item List Up (1 element)
        fk->SetTopItem( fk->GetTopItem() - 1 );
        if( fk->GetTopItem() < 0 )
          fk->SetTopItem( 0 );
        else {
          SET_INT( fk_int->item_scroll, fk->GetTopItem() );
          fk_int->RedrawItemList();
        }
      }
      break;

    case DK_SC_DOWN:
      if( fk_int->shift_down ) {        // Jump to the bottom of the Item List
        fk->SetTopItem( max_top );
        SET_INT( fk_int->item_scroll, fk->GetTopItem() );
        fk_int->RedrawItemList();
      } else if( fk_int->alt_down && fk_int->ctrl_down ) {
        ;
      } else if( fk_int->alt_down ) {   // Scroll Group List Down (1 element)
        GET_INT( fk_int->group_list, value );
        if( value < (int)fk->GetGroupList().NumElements() - 2 ) {   // Don't go to (new group)!
          SET_INT( fk_int->group_list, ++value );
          OnGroupList( fk_int->group_list, fk_int );
        }
      } else if( fk_int->ctrl_down ) {  // Scroll Item List Down (1 page)
        fk->SetTopItem( fk->GetTopItem() + list_height );
        if( fk->GetTopItem() > max_top )
          fk->SetTopItem( max_top );
        SET_INT( fk_int->item_scroll, fk->GetTopItem() );
        fk_int->RedrawItemList();
      } else {                          // Scroll Item List Down (1 element)
        fk->SetTopItem( fk->GetTopItem() + 1 );
        if( fk->GetTopItem() > max_top )
          fk->SetTopItem( max_top );
        else {
          SET_INT( fk_int->item_scroll, fk->GetTopItem() );
          fk_int->RedrawItemList();
        }
      }
      break;

    case DK_RETURN:
    case DK_PAD_ENTER:
    case '\r':
      if( fk_int->shift_down )          // Add selected to group (Apply)
        OnGroupEditApply( fk_int->group_edit_apply, fk_int );
      else                              // Add to selection (Apply)
        OnApplySelection( fk_int->apply_select_item_name, fk_int );
      break;

    case DK_F1:                         // Keyboard Help
    case DK_HELP:
      OnF1( fk_int->f1, fk_int );
      break;

    case DK_CHAR('='):                  // Add a New Group
    case DK_CHAR('+'):
      fk->SetCurrentGroup( fk->GetGroupList().NumElements() - 1 );
      OnGroupList( fk_int->group_list, fk_int );
      break;

    case DK_CHAR('-'):                  // Remove an Existing Group
      OnGroupDel( fk_int->group_delete, fk_int );
      break;

    case DK_CHAR('['):                  // Scroll Selection Mode Up (1 element)
      GET_INT( fk_int->select_item_mode, value );
      if( value > 0 ) {
        SET_INT( fk_int->select_item_mode, --value );
        OnSelectionMode( fk_int->select_item_mode, fk_int );
      }
      break;

    case DK_CHAR(']'):                  // Scroll Selection Mode Down (1 element)
      GET_INT( fk_int->select_item_mode, value );
      if( value < num_selection_modes - 1) {
        SET_INT( fk_int->select_item_mode, ++value );
        OnSelectionMode( fk_int->select_item_mode, fk_int );
      }
      break;

    case DK_CHAR('{'):                  // Scroll the Group Edit Mode Up (1 element)
      GET_INT( fk_int->group_edit_mode, value );
      if( value > 0 )
        SET_INT( fk_int->group_edit_mode, --value );
      break;

    case DK_CHAR('}'):                  // Scroll the Group Edit Mode Up (1 element)
      GET_INT( fk_int->group_edit_mode, value );
      if( value < num_group_edit_modes - 1 )
        SET_INT( fk_int->group_edit_mode, ++value );
      break;

    case DK_CHAR(' '):                  // Cycle Select/Deselect/Invert
      GET_INT( fk_int->select_toggle, value );
      if( value < num_selection_toggles - 1)
        SET_INT( fk_int->select_toggle, ++value );
      else
        SET_INT( fk_int->select_toggle, 0 );

      OnSelectionMode( fk_int->select_item_mode, fk_int );
      break;

    case DK_CHAR('f'):                  // Fold/Unfold Current Item
      if( fk->IsCurrentItemValid() ) {
        fk_int->sorted_items[ fk->GetCurrentItem() ]->SetFolded( !fk_int->sorted_items[ fk->GetCurrentItem() ]->GetFolded() );
        fk_int->sorted_items.Reset();                       // Rebuild item list to represent fold states
        if( fk->GetScene().GetBaseItem().GetChildren().NumElements() > 0 )
          fk->GetScene().GetBaseItem().BuildFoldedItemList( fk_int->sorted_items, true, false );

        if( fk->GetCurrentItem() > fk_int->sorted_items.NumElements() - 1 )
          fk->SetCurrentItem( fk_int->sorted_items.NumElements() - 1 );

        OnDisplayMode( fk_int->display_item_mode, fk_int );
      }
      break;

    case DK_CHAR('F'):                  // Fold/Unfold All Items
      last_was_folded = !last_was_folded;
      if( last_was_folded )
        OnFoldList( fk_int->list_fold, fk_int );
      else 
        OnUnFoldList( fk_int->list_unfold, fk_int );

      OnDisplayMode( fk_int->display_item_mode, fk_int );
      break;

    case DK_CHAR('a'):
      if( fk_int->alt_down ||           // Select All
          fk_int->ctrl_down ) {
        SelectAll();
        fk_int->RedrawItemList();
        fk_int->UpdateSelectedCount();
      }
      break;

    case DK_CHAR('/'):                  // Deselect All
      DeselectAll();
      fk_int->UpdateSelectedCount();
      fk_int->RedrawItemList();
      break;

    case DK_CHAR('c'):
      if( fk_int->alt_down ) {          // Select Children
        SelectChildren();
        fk_int->UpdateSelectedCount();
      } else {                          // Select Current And It's Children
        fk_int->UpdateSelectedCount();
        SelectItem( fk_int->sorted_items[ fk->GetCurrentItem() ], true );
      }

      fk_int->RedrawItemList();
      break;

    case DK_CHAR('C'):                   // Deselect Current And It's Children
      DeselectItem( fk_int->sorted_items[ fk->GetCurrentItem() ], true );
      fk_int->UpdateSelectedCount();
      fk_int->RedrawItemList();
      break;

    case DK_CHAR('g'):
      if( fk_int->alt_down ||            // Add Selected To Group
          fk_int->ctrl_down ) {
        SetSelectionToGroup( fk->GetCurrentGroup() );
        fk_int->RedrawItemList();
      } else {                           // Select all in group
        SelectAllInGroup( fk->GetCurrentGroup(), false );
        fk_int->RedrawItemList();
      }
      break;

    case DK_CHAR('G'):                   // Deselect all in group
      DeselectAllInGroup( fk->GetCurrentGroup(), false );
      fk_int->UpdateSelectedCount();
      fk_int->RedrawItemList();
      break;

    case DK_CHAR( 9 ):                   // Cyle Display Mode -
      GET_INT( fk_int->display_item_mode, value );
      if( fk_int->shift_down ) {         // - Backward
        if( --value < 0 ) { value = 0; }
      } else {                           // - Forward
        if( ++value > 7 ) { value = 7; }
      }

      SET_INT( fk_int->display_item_mode, value );
      OnDisplayMode( fk_int->display_item_mode, fk_int );
      break;

    case DK_CHAR( '`' ):                 // Draw Style (that's the tilde key)
      if( fk->GetDrawStyle() == DRAWSTYLE_56 ) {
        fk->SetDrawStyle( DRAWSTYLE_L6 );
        fk_int->SetStatusText( "Now using L6 Draw Style", STATUSMODE_INFO, true );
      } else {
        fk->SetDrawStyle( DRAWSTYLE_56 );
        fk_int->SetStatusText( "Now using 5.6 Draw Style", STATUSMODE_INFO, true );
      }
      SET_INT( fk_int->opt_draw_style, fk->GetDrawStyle() );
      fk_int->RedrawItemList();
      break;
  }
}
コード例 #8
0
ファイル: ui.c プロジェクト: DimondTheCat/xray
int get_user( UnwrapParams *uwp )
{
   static char *text[] = {
      "Draws polygons in the 2D coordinate system of the selected texture layer.",
      NULL
   };
   static char *fgopt[] = {
      "Use Color",
      "Invert Background",
      "Brighten",
      "Darken",
      NULL
   };
   static char *bgopt[] = {
      "Use Color",
      "Copy Image Map",
      NULL
   };

   LWPanControlDesc desc;
   LWValue
      ival    = { LWT_INTEGER },
      sval    = { LWT_STRING },
      ivecval = { LWT_VINT };
   LWPanelID panel;
   LWControl *ctl[ 10 ], *bdr[ 2 ];
   Node *root;
   int i, x, y, w, ph, ok;


   root = make_list( panf->globalFun );
   if ( !root ) return 0;

   if( !( panel = PAN_CREATE( panf, "Unwrap" ))) {
      free_tree( root, 1 );
      return 0;
   }

   if ( !uwp->filename[ 0 ] ) {
      strcpy( uwp->filename, "unwrapped" );
      filename_ext( uwp->saver, uwp->filename );
      uwp->bgcolor[ 0 ] = uwp->bgcolor[ 1 ] = uwp->bgcolor[ 2 ] = 255;
   }

   TEXT_CTL( panf, panel, "", text );

   ctl[ 0 ] = TREE_CTL( panf, panel, "Texture Layer", 200, 200, tree_info,
      tree_count, tree_child );

   ph = PAN_GETH( panf, panel );
   ph -= CON_X( ctl[ 0 ] );
   ph -= CON_H( ctl[ 0 ] );

   ctl[ 1 ] = SAVE_CTL( panf, panel, "Save As", 40 );
   ctl[ 2 ] = CUSTPOPUP_CTL( panf, panel, "", 150, sname, scount );
   ctl[ 3 ] = INT_CTL( panf, panel, "Width" );
   ctl[ 4 ] = INT_CTL( panf, panel, "Height" );
   ctl[ 5 ] = BUTTON_CTL( panf, panel, "From Image Map" );
   ctl[ 6 ] = WPOPUP_CTL( panf, panel, "Edges", fgopt, 150 );
   ctl[ 7 ] = MINIRGB_CTL( panf, panel, "" );
   ctl[ 8 ] = WPOPUP_CTL( panf, panel, "Background", bgopt, 150 );
   ctl[ 9 ] = MINIRGB_CTL( panf, panel, "" );

   w = CON_W( ctl[ 1 ] );
   w -= CON_LW( ctl[ 1 ] );

   bdr[ 0 ] = BORDER_CTL( panf, panel, "", w, 2 );
   bdr[ 1 ] = BORDER_CTL( panf, panel, "", w, 2 );

   x = CON_X( ctl[ 0 ] );
   x += CON_W( ctl[ 0 ] );
   x += CON_LW( ctl[ 8 ] ) + 8;
   y = CON_Y( ctl[ 0 ] );

   w = CON_LW( ctl[ 1 ] );
   MOVE_CON( ctl[ 1 ], x - w, y );

   w = CON_LW( ctl[ 2 ] );
   y += CON_HOTH( ctl[ 1 ] ) + 4;
   MOVE_CON( ctl[ 2 ], x - w, y );

   y += CON_HOTH( ctl[ 2 ] ) + 6;
   MOVE_CON( bdr[ 0 ], x, y );

   w = CON_LW( ctl[ 3 ] );
   y += 6;
   MOVE_CON( ctl[ 3 ], x - w, y );

   w = CON_X( ctl[ 3 ] );
   w += CON_W( ctl[ 3 ] );
   MOVE_CON( ctl[ 5 ], w + 16, y );

   w = CON_LW( ctl[ 4 ] );
   y += CON_HOTH( ctl[ 3 ] ) + 4;
   MOVE_CON( ctl[ 4 ], x - w, y );

   y += CON_HOTH( ctl[ 2 ] ) + 6;
   MOVE_CON( bdr[ 1 ], x, y );

   y += 6;
   for ( i = 6; i <= 9; i++ ) {
      w = CON_LW( ctl[ i ] );
      MOVE_CON( ctl[ i ], x - w, y );
      y += CON_HOTH( ctl[ i ] ) + 4;
   }

   y = CON_Y( ctl[ 9 ] );
   y += CON_H( ctl[ 9 ] );
   PAN_SETH( panf, panel, y + ph );

   SET_STR( ctl[ 1 ], uwp->filename, sizeof( uwp->filename ));
   SET_INT( ctl[ 2 ], uwp->saver );
   SET_INT( ctl[ 3 ], uwp->width );
   SET_INT( ctl[ 4 ], uwp->height );
   SET_INT( ctl[ 6 ], uwp->fgoptions );
   SET_INT( ctl[ 8 ], uwp->bgoptions );
   SETV_IVEC( ctl[ 7 ], uwp->fgcolor );
   SETV_IVEC( ctl[ 9 ], uwp->bgcolor );

   CON_SETEVENT( ctl[ 0 ], tree_event, root );
   CON_SETEVENT( ctl[ 2 ], saver_event, ctl[ 1 ] );
   CON_SETEVENT( ctl[ 5 ], sizebtn_event, ctl );

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

   if ( ok ) {
      GET_STR( ctl[ 1 ], uwp->filename, sizeof( uwp->filename ));
      GET_INT( ctl[ 2 ], uwp->saver );
      GET_INT( ctl[ 3 ], uwp->width );
      GET_INT( ctl[ 4 ], uwp->height );
      GET_INT( ctl[ 6 ], uwp->fgoptions );
      GET_INT( ctl[ 8 ], uwp->bgoptions );
      GETV_IVEC( ctl[ 7 ], uwp->fgcolor );
      GETV_IVEC( ctl[ 9 ], uwp->bgcolor );

      ctl[ 0 ]->get( ctl[ 0 ], CTL_VALUE, &ival );
      if ( !getsel_tree( uwp, ( Node * ) ival.ptr.ptr )) {
         msgf->error( "No texture layer selected", NULL );
         ok = 0;
      }
   }

   PAN_KILL( panf, panel );

   free_tree( root, 1 );
   return ok;
}
コード例 #9
0
ファイル: dna.c プロジェクト: DimondTheCat/xray
static void ctl_create( void )
{
   static char *labatype[] = { "Point", "Sphere", "Dodec", NULL };
   static char *labbtype[] = { "Line", "Cylinder", NULL };
   static char *labradii[] = { "Radii", NULL };
   int x, y, w, h, ph, i;


   /* create a control */

   ctl[ 0 ] = STR_CTL( panf, panel, "Sequence", 40 );

   /* find out how much vertical space the panel wants for drawing its
      own decorations, and get some other panel metrics */

   ph = PAN_GETH( panf, panel ) - CON_H( ctl[ 0 ] );
   dmet = panf->drawFuncs->dispMetrics();

   /* create the rest of the controls */

   ctl[  1 ] = WPOPUP_CTL( panf, panel, "Atoms", labatype, 100 );
   ctl[  2 ] = INT_CTL( panf, panel, "Sides" );
   ctl[  3 ] = INT_CTL( panf, panel, "Segments" );
   ctl[  4 ] = TEXT_CTL( panf, panel, "", labradii );
   ctl[  5 ] = FLOAT_CTL( panf, panel, "Carbon" );
   ctl[  6 ] = FLOAT_CTL( panf, panel, "Hydrogen" );
   ctl[  7 ] = FLOAT_CTL( panf, panel, "Nitrogen" );
   ctl[  8 ] = FLOAT_CTL( panf, panel, "Oxygen" );
   ctl[  9 ] = FLOAT_CTL( panf, panel, "Phosphorus" );
   ctl[ 10 ] = WPOPUP_CTL( panf, panel, "Bonds", labbtype, 100 );
   ctl[ 11 ] = INT_CTL( panf, panel, "Sides" );
   ctl[ 12 ] = INT_CTL( panf, panel, "Segments" );
   ctl[ 13 ] = FLOAT_CTL( panf, panel, "Radius" );
   ctl[ 14 ] = BOOL_CTL( panf, panel, "Base Plates" );

   w = 2 * panf->drawFuncs->textWidth( panel, "Polygons:" ) + 16;
   ctl[ 15 ] = CANVAS_CTL( panf, panel, "", w, 3 * dmet->textHeight );

   /* position all of the controls */

   x = CON_X( ctl[ 0 ] );
   x += CON_W( ctl[ 1 ] );
   h = CON_HOTH( ctl[ 1 ] ) + 4;

   w = CON_W( ctl[ 1 ] );
   y = CON_Y( ctl[ 0 ] ) + 3 * h / 2;
   MOVE_CON( ctl[ 1 ], x - w, y );

   w = CON_W( ctl[ 2 ] );
   MOVE_CON( ctl[ 2 ], x - w, y + 3 * h / 2 );

   w = CON_W( ctl[ 3 ] );
   y = CON_Y( ctl[ 2 ] );
   MOVE_CON( ctl[ 3 ], x - w, y + h );

   w = CON_W( ctl[ 4 ] );
   y = CON_Y( ctl[ 3 ] );
   MOVE_CON( ctl[ 4 ], ( x - w ) / 2, y + 3 * h / 2 );

   for ( i = 5; i < 10; i++ ) {
      w = CON_W( ctl[ i ] );
      y = CON_Y( ctl[ i - 1 ] );
      MOVE_CON( ctl[ i ], x - w, y + h );
   }

   x = x * 2 + 10;
   w = CON_W( ctl[ 10 ] );
   y = CON_Y( ctl[ 1 ] );
   MOVE_CON( ctl[ 10 ], x - w, y );

   w = CON_W( ctl[ 11 ] );
   y = CON_Y( ctl[ 10 ] );
   MOVE_CON( ctl[ 11 ], x - w, y + 3 * h / 2 );

   w = CON_W( ctl[ 12 ] );
   y = CON_Y( ctl[ 11 ] );
   MOVE_CON( ctl[ 12 ], x - w, y + h );

   w = CON_W( ctl[ 13 ] );
   y = CON_Y( ctl[ 12 ] );
   MOVE_CON( ctl[ 13 ], x - w, y + 3 * h / 2 );

   w = CON_W( ctl[ 14 ] );
   y = CON_Y( ctl[ 13 ] );
   MOVE_CON( ctl[ 14 ], x - w, y + 3 * h / 2 );

   w = CON_W( ctl[ 15 ] );
   y = CON_Y( ctl[ 14 ] );
   MOVE_CON( ctl[ 15 ], x - w, y + 2 * h );

   /* now that we know how much room the controls will take up, set the
      height of the panel */

   h = CON_Y( ctl[ 9 ] );
   h += CON_HOTH( ctl[ 9 ] );
   PAN_SETH( panf, panel, h + ph - 6 );

   /* initialize the controls */

   ctl_set();

   /* set the event handlers and user data */

   for ( i = 0; i < 15; i++ )
      CON_SETEVENT( ctl[ i ], ctl_event, NULL );

   ival.ptr.ptr = ctl_draw;
   ctl[ 15 ]->set( ctl[ 15 ], CTL_USERDRAW, &ival );
}
コード例 #10
0
// OpenUI():
//  Opens the user interface.  Returns after the panel has been closed.
bool ReplaceObjects_Interface::OpenUI() {
  // Destroy the panel if it hasn't been destroyed yet
  if( panel != NULL ) {
    (*panel_funcs->destroy)( panel );
    panel = NULL;
  }

  char title_string[256];
  sprintf( title_string, "ReplaceObjects -- %c2001 Joe Angell, TM Productions", 169 );
  panel = (*panel_funcs->create)( title_string, panel_funcs );
  if( !panel ) {                    // Make sure the panel was created
    (*message->error)("Error creating main panel, aborting", NULL );
    return false;
  }

  // Limit To Pop-Up
  limit_to_popup = WPOPUP_CTL( panel_funcs, panel, "Limit To",
                               limit_to_popup_strings, 110 );

  // Sort By Pop-Up
  sort_by_popup = WPOPUP_CTL( panel_funcs, panel, "Sort By",
                              sort_by_popup_strings, 110 );
  PanelTools::PutOnLineWith( limit_to_popup, sort_by_popup, 10 );

  // Match
  match_toggle = BOOL_CTL( panel_funcs, panel, "Match Name" );
  match_string = STR_CTL(  panel_funcs, panel, "Name Contains", 41 );
  PanelTools::PutOnLineWith( match_toggle, match_string, 10 );

  // List
  list = MULTILIST_CTL( panel_funcs, panel, "Swap Objects",
                        300, 20, ListNames, ListCount, ListColumnWidths );
  PanelTools::PutUnder( match_toggle, list, 20 );

  // Add
  add = WBUTTON_CTL( panel_funcs, panel, "Add", 60 );
  PanelTools::PutOnLineWith( list, add, 3);

  // Clone
  clone = WBUTTON_CTL( panel_funcs, panel, "Clone", 60 );
  PanelTools::AlignLabels( add, clone );

  // Remove
  remove = WBUTTON_CTL( panel_funcs, panel, "Remove", 60 );
  PanelTools::AlignLabels( clone, remove );

  // Clear All
  clear_all  = WBUTTON_CTL( panel_funcs, panel, "Clear All", 60 );
  PanelTools::AlignLabels( remove, clear_all );
  PanelTools::PutUnder( clear_all, clear_all );

  // About
  about = WBUTTON_CTL( panel_funcs, panel, "About", 60 );
  PanelTools::PutOnLineWith( sort_by_popup, about );

  // Load
  load = LOADBUTTON_CTL( panel_funcs, panel, "Load", 60 );
  PanelTools::PutOnLineWith( sort_by_popup, about );

  // Save
  save = SAVEBUTTON_CTL( panel_funcs, panel, "Save", 60 );
  PanelTools::PutOnLineWith( sort_by_popup, about );

  // Path
  path = FILE_CTL( panel_funcs, panel, "Object Path", 59 );
  PanelTools::PutUnder( list, path, 18 );

  // Weight
  weight = FLOAT_CTL( panel_funcs, panel, "Weight" );
  PanelTools::AlignLabels( path, weight );

  // Enable
  enable = BOOL_CTL( panel_funcs, panel, "Enable" );
  PanelTools::PutOnLineWith( weight, enable );

  // Store Original Names
  store_original_name = BOOL_CTL( panel_funcs, panel, "Store Original Object Name As Tag" );
  SET_INT( store_original_name, store_original_name_value );
  PanelTools::AlignLabels( weight, store_original_name, 18 );

  int x  = CON_X( add );
  int y  = CON_Y( list );
  int h  = CON_H( list );
  int h2 = CON_H( about );
  MOVE_CON( about, x, (y + h) - h2 );
  MOVE_CON( save,  x, (y + h) - (h2 * 3) + 10 );
  MOVE_CON( load,  x, (y + h) - (h2 * 4) + 15 );

  // Default Values
  SET_INT( list, -1 );
  HandleList( list, NULL );

  // Event Handlers
  CON_SETEVENT( list,          HandleList,        NULL );
  CON_SETEVENT( about,         HandleAbout,       NULL );

  CON_SETEVENT( sort_by_popup, HandleSortBy,      NULL );
  CON_SETEVENT( match_toggle,  HandleMatchToggle, NULL );

  CON_SETEVENT( add,           HandleAdd,         NULL );
  CON_SETEVENT( clone,         HandleClone,       NULL );
  CON_SETEVENT( remove,        HandleRemove,      NULL );
  CON_SETEVENT( clear_all,     HandleClearAll,    NULL );

  CON_SETEVENT( load,          HandleLoad,        NULL );
  CON_SETEVENT( save,          HandleSave,        NULL );

  CON_SETEVENT( path,          HandlePath,        NULL );
  CON_SETEVENT( weight,        HandleWeight,      NULL );
  CON_SETEVENT( enable,        HandleEnable,      NULL );

  // Panel-Level Callbacks
  (*panel_funcs->set)( panel, PAN_USERDRAW, DrawPanel );

  // Get a copy of the swaps
  swaps.Flush();
  ReplaceObjects_SwapObject *new_swap;
  for( unsigned long i=0; i < old_swaps.NumElements(); i++ ) {
    new_swap = new ReplaceObjects_SwapObject;
    *new_swap = *old_swaps[i];
    swaps.Add( new_swap );
  }

  HandleMatchToggle( match_toggle, NULL );

  // Open the Panel
  int retval = (*panel_funcs->open)( panel, PANF_BLOCKING | PANF_CANCEL | PANF_PASSALLKEYS );
  if( retval > 0 ) {
    do_process = true;
    GET_INT( store_original_name, store_original_name_value );

    old_swaps.Flush();
    ReplaceObjects_SwapObject *new_swap;
    for( unsigned long i=0; i < swaps.NumElements(); i++ ) {
      new_swap = new ReplaceObjects_SwapObject;
      *new_swap = *swaps[i];
      old_swaps.Add( new_swap );
    }
  }

  return do_process;
}