Linux fixes.

This commit is contained in:
leo 2012-07-06 01:18:55 +00:00
parent 1d72f82c9b
commit 2e73fdfe71
5 changed files with 274 additions and 311 deletions

View file

@ -528,7 +528,7 @@ static int lcGetMinifigSettings(lcMemFile& File)
do
{
strm.avail_in = min(sizeof(sDefaultSettings) - pos, CHUNK);
strm.avail_in = lcMin(sizeof(sDefaultSettings) - pos, CHUNK);
strm.next_in = in;
if (strm.avail_in == 0)

View file

@ -339,10 +339,10 @@ void Piece::InsertTime (unsigned short start, bool animation, unsigned short tim
if (animation)
{
if (m_nFrameShow >= start)
m_nFrameShow = min(m_nFrameShow + time, lcGetActiveProject()->GetTotalFrames());
m_nFrameShow = lcMin(m_nFrameShow + time, lcGetActiveProject()->GetTotalFrames());
if (m_nFrameHide >= start)
m_nFrameHide = min(m_nFrameHide + time, lcGetActiveProject()->GetTotalFrames());
m_nFrameHide = lcMin(m_nFrameHide + time, lcGetActiveProject()->GetTotalFrames());
if (m_nFrameShow > lcGetActiveProject()->GetCurrentTime())
Select (false, false, false);
@ -350,10 +350,10 @@ void Piece::InsertTime (unsigned short start, bool animation, unsigned short tim
else
{
if (m_nStepShow >= start)
m_nStepShow = min(m_nStepShow + time, 255);
m_nStepShow = lcMin(m_nStepShow + time, 255);
if (m_nStepHide >= start)
m_nStepHide = min(m_nStepHide + time, 255);
m_nStepHide = lcMin(m_nStepHide + time, 255);
if (m_nStepShow > lcGetActiveProject()->GetCurrentTime ())
Select (false, false, false);
@ -367,12 +367,12 @@ void Piece::RemoveTime (unsigned short start, bool animation, unsigned short tim
if (animation)
{
if (m_nFrameShow >= start)
m_nFrameShow = max(m_nFrameShow - time, 1);
m_nFrameShow = lcMax(m_nFrameShow - time, 1);
if (m_nFrameHide == lcGetActiveProject()->GetTotalFrames())
m_nFrameHide = lcGetActiveProject()->GetTotalFrames();
else
m_nFrameHide = max(m_nFrameHide - time, 1);
m_nFrameHide = lcMax(m_nFrameHide - time, 1);
if (m_nFrameHide < lcGetActiveProject()->GetCurrentTime())
Select (false, false, false);
@ -380,10 +380,10 @@ void Piece::RemoveTime (unsigned short start, bool animation, unsigned short tim
else
{
if (m_nStepShow >= start)
m_nStepShow = max (m_nStepShow - time, 1);
m_nStepShow = lcMax(m_nStepShow - time, 1);
if (m_nStepHide != 255)
m_nStepHide = max (m_nStepHide - time, 1);
m_nStepHide = lcMax(m_nStepHide - time, 1);
if (m_nStepHide < lcGetActiveProject()->GetCurrentTime())
Select (false, false, false);

View file

@ -2566,7 +2566,7 @@ void Project::RenderOverlays(View* view)
// Draw circle.
glBegin(GL_LINE_LOOP);
float r = min(w, h) * 0.35f;
float r = lcMin(w, h) * 0.35f;
float cx = x + w / 2.0f;
float cy = y + h / 2.0f;
@ -2580,7 +2580,7 @@ void Project::RenderOverlays(View* view)
glEnd();
const float OverlayCameraSquareSize = max(8.0f, (w+h)/200);
const float OverlayCameraSquareSize = lcMax(8.0f, (w+h)/200);
// Draw squares.
glBegin(GL_LINE_LOOP);
@ -3094,7 +3094,7 @@ unsigned char Project::GetLastStep()
{
unsigned char last = 1;
for (Piece* pPiece = m_pPieces; pPiece; pPiece = pPiece->m_pNext)
last = max(last, pPiece->GetStepShow());
last = lcMax(last, pPiece->GetStepShow());
return last;
}
@ -3414,10 +3414,10 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam)
if (SystemDoDialog(LC_DLG_PICTURE_SAVE, &opts))
{
if (m_bAnimation)
opts.to = min(opts.to, m_nTotalFrames);
opts.to = lcMin(opts.to, m_nTotalFrames);
else
opts.to = min(opts.to, 255);
opts.from = max(1, opts.from);
opts.to = lcMin(opts.to, 255);
opts.from = lcMax(1, opts.from);
if (opts.multiple)
{
@ -6479,7 +6479,7 @@ bool Project::StopTracking(bool bAccept)
// Zoom in/out.
float RatioX = (Right - Left) / Viewport[2];
float RatioY = (Top - Bottom) / Viewport[3];
float ZoomFactor = -max(RatioX, RatioY) + 0.75f;
float ZoomFactor = -lcMax(RatioX, RatioY) + 0.75f;
lcVector3 Dir = Points[1] - Points[2];
Eye = Eye + Dir * ZoomFactor;
@ -6575,8 +6575,8 @@ void Project::GetSnapDistance(float* SnapXY, float* SnapZ) const
int SXY, SZ;
GetSnapIndex(&SXY, &SZ, NULL);
SXY = min(SXY, 9);
SZ = min(SZ, 9);
SXY = lcMin(SXY, 9);
SZ = lcMin(SZ, 9);
*SnapXY = SnapXYTable[SXY];
*SnapZ = SnapZTable[SZ];
@ -6601,8 +6601,8 @@ void Project::GetSnapDistanceText(char* SnapXY, char* SnapZ) const
int SXY, SZ;
GetSnapIndex(&SXY, &SZ, NULL);
SXY = min(SXY, 9);
SZ = min(SZ, 9);
SXY = lcMin(SXY, 9);
SZ = lcMin(SZ, 9);
strcpy(SnapXY, SnapXYText[SXY]);
strcpy(SnapZ, SnapZText[SZ]);
@ -8709,9 +8709,9 @@ void Project::MouseUpdateOverlays(View* view, int x, int y)
int cy = vy + vh / 2;
float d = sqrtf((float)((cx - x) * (cx - x) + (cy - y) * (cy - y)));
float r = min(vw, vh) * 0.35f;
float r = lcMin(vw, vh) * 0.35f;
const float SquareSize = max(8.0f, (vw+vh)/200);
const float SquareSize = lcMax(8.0f, (vw+vh)/200);
if ((d < r + SquareSize) && (d > r - SquareSize))
{

View file

@ -501,12 +501,12 @@ void Terrain::SetControlPoints()
m_Patches[i][j].control[(a*4+b)*3+1] = m_pControl[i*(4-1)+a][(j*(4-1)+b)*3+1];
m_Patches[i][j].control[(a*4+b)*3+2] = m_pControl[i*(4-1)+a][(j*(4-1)+b)*3+2];
minX = min(minX, m_Patches[i][j].control[(a*4+b)*3]);
maxX = max(maxX, m_Patches[i][j].control[(a*4+b)*3]);
minY = min(minY, m_Patches[i][j].control[(a*4+b)*3+1]);
maxY = max(maxY, m_Patches[i][j].control[(a*4+b)*3+1]);
minZ = min(minZ, m_Patches[i][j].control[(a*4+b)*3+2]);
maxZ = max(maxZ, m_Patches[i][j].control[(a*4+b)*3+2]);
minX = lcMin(minX, m_Patches[i][j].control[(a*4+b)*3]);
maxX = lcMax(maxX, m_Patches[i][j].control[(a*4+b)*3]);
minY = lcMin(minY, m_Patches[i][j].control[(a*4+b)*3+1]);
maxY = lcMax(maxY, m_Patches[i][j].control[(a*4+b)*3+1]);
minZ = lcMin(minZ, m_Patches[i][j].control[(a*4+b)*3+2]);
maxZ = lcMax(maxZ, m_Patches[i][j].control[(a*4+b)*3+2]);
}
m_Patches[i][j].InitBox(minX, maxX, minY, maxY, minZ, maxZ);
}

View file

@ -30,380 +30,343 @@
struct LC_MINIFIGDLG_STRUCT
{
MinifigWizard* wizard;
GtkWidget *pieces[LC_MFW_NUMITEMS];
GtkWidget *colors[LC_MFW_NUMITEMS];
GtkWidget *angles[LC_MFW_NUMITEMS];
GtkWidget *preview;
GtkWidget *combo;
MinifigWizard* wizard;
GtkWidget *pieces[LC_MFW_NUMITEMS];
GtkWidget *colors[LC_MFW_NUMITEMS];
GtkWidget *angles[LC_MFW_NUMITEMS];
GtkWidget *preview;
GtkWidget *combo;
GtkWidget *dlg;
};
// User wants to add the minifig to the project
static void minifigdlg_ok(GtkWidget *widget, gpointer data)
{
// LC_MINIFIGDLG_STRUCT* s = (LC_MINIFIGDLG_STRUCT*)data;
// LC_MINIFIGDLG_OPTS* opts = (LC_MINIFIGDLG_OPTS*)s->data;
dlg_end (LC_OK);
}
// A new color was selected from the menu
static void minifigdlg_color_response (GtkWidget *widget, gpointer data)
static void minifigdlg_color_response(GtkWidget *widget, gpointer data)
{
LC_MINIFIGDLG_STRUCT* info;
GtkWidget* button;
int i;
LC_MINIFIGDLG_STRUCT* info;
GtkWidget* button;
int i;
button = (GtkWidget*)gtk_object_get_data (GTK_OBJECT (widget), "button");
info = (LC_MINIFIGDLG_STRUCT*)gtk_object_get_data (GTK_OBJECT (button), "info");
button = (GtkWidget*)gtk_object_get_data(GTK_OBJECT(widget), "button");
info = (LC_MINIFIGDLG_STRUCT*)gtk_object_get_data(GTK_OBJECT(button), "info");
if (!info)
return;
if (!info)
return;
for (i = 0; i < 15; i++)
if (info->colors[i] == button)
break;
for (i = 0; i < 15; i++)
if (info->colors[i] == button)
break;
info->wizard->SetColor (i, GPOINTER_TO_INT (data));
info->wizard->Redraw ();
set_button_pixmap2(button, gColorList[GPOINTER_TO_INT(data)].Value);
info->wizard->SetColor(i, GPOINTER_TO_INT(data));
info->wizard->Redraw();
set_button_pixmap2(button, gColorList[GPOINTER_TO_INT(data)].Value);
}
// A color button was clicked
static void minifigdlg_color_clicked (GtkWidget *widget, gpointer data)
static void minifigdlg_color_clicked(GtkWidget *widget, gpointer data)
{
int i;
GtkWidget *menu, *menuitem;
int i;
GtkWidget *menu, *menuitem;
menu = gtk_menu_new ();
menu = gtk_menu_new();
for (i = 0; i < gNumUserColors; i++)
{
menuitem = gtk_menu_item_new_with_label(gColorList[i].Name);
gtk_widget_show(menuitem);
gtk_menu_append(GTK_MENU(menu), menuitem);
for (i = 0; i < gNumUserColors; i++)
{
menuitem = gtk_menu_item_new_with_label(gColorList[i].Name);
gtk_widget_show(menuitem);
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_object_set_data(GTK_OBJECT(menuitem), "button", widget);
gtk_signal_connect(GTK_OBJECT(menuitem), "activate", GTK_SIGNAL_FUNC(minifigdlg_color_response), (void*)i);
}
gtk_object_set_data(GTK_OBJECT(menuitem), "button", widget);
gtk_signal_connect(GTK_OBJECT(menuitem), "activate", GTK_SIGNAL_FUNC(minifigdlg_color_response), (void*)i);
}
gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 0, 0);
gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 0, 0);
}
// New piece was selected
static void minifigdlg_piece_changed (GtkWidget *widget, gpointer data)
static void minifigdlg_piece_changed(GtkWidget *widget, gpointer data)
{
LC_MINIFIGDLG_STRUCT* info;
int i, piece_type = -1, piece_index = -1;
const gchar* desc;
LC_MINIFIGDLG_STRUCT* info;
int i, piece_type = -1, piece_index = -1;
const gchar* desc;
info = (LC_MINIFIGDLG_STRUCT*)gtk_object_get_data (GTK_OBJECT (widget), "info");
if (info == NULL)
return;
info = (LC_MINIFIGDLG_STRUCT*)gtk_object_get_data(GTK_OBJECT(widget), "info");
if (info == NULL)
return;
for (i = 0; i < LC_MFW_NUMITEMS; i++)
if (GTK_COMBO (info->pieces[i])->entry == widget)
{
piece_type = i;
break;
}
for (i = 0; i < LC_MFW_NUMITEMS; i++)
if (GTK_COMBO(info->pieces[i])->entry == widget)
{
piece_type = i;
break;
}
ObjArray<lcMinifigPieceInfo>& InfoArray = info->wizard->mSettings[piece_type];
desc = gtk_entry_get_text (GTK_ENTRY (widget));
ObjArray<lcMinifigPieceInfo>& InfoArray = info->wizard->mSettings[piece_type];
desc = gtk_entry_get_text(GTK_ENTRY(widget));
for (i = 0; i < InfoArray.GetSize(); i++)
{
if (!strcmp(InfoArray[i].Description, desc))
{
piece_index = i;
break;
}
}
for (i = 0; i < InfoArray.GetSize(); i++)
{
if (!strcmp(InfoArray[i].Description, desc))
{
piece_index = i;
break;
}
}
if (piece_index == -1 || piece_type == -1)
return;
info->wizard->SetSelectionIndex (piece_type, piece_index);
info->wizard->Redraw ();
info->wizard->SetSelectionIndex(piece_type, piece_index);
info->wizard->Redraw();
}
static void minifigdlg_updatecombo (LC_MINIFIGDLG_STRUCT* s)
static void minifigdlg_updatecombo(LC_MINIFIGDLG_STRUCT* s)
{
char **names;
int count;
GList *lst = NULL;
char **names;
int count;
GList *lst = NULL;
s->wizard->GetMinifigNames (&names, &count);
for (int i = 0; i < count; i++)
lst = g_list_append (lst, names[i]);
s->wizard->GetMinifigNames(&names, &count);
for (int i = 0; i < count; i++)
lst = g_list_append(lst, names[i]);
if (lst == NULL)
lst = g_list_append (lst, (void*)"");
if (lst == NULL)
lst = g_list_append(lst, (void*)"");
gtk_combo_set_popdown_strings (GTK_COMBO (s->combo), lst);
g_list_free (lst);
gtk_combo_set_popdown_strings(GTK_COMBO(s->combo), lst);
g_list_free(lst);
}
static void minifigdlg_updateselection (LC_MINIFIGDLG_STRUCT* s)
static void minifigdlg_updateselection(LC_MINIFIGDLG_STRUCT* s)
{
for (int i = 0; i < LC_MFW_NUMITEMS; i++)
{
int index = s->wizard->GetSelectionIndex(i);
for (int i = 0; i < LC_MFW_NUMITEMS; i++)
{
int index = s->wizard->GetSelectionIndex(i);
GtkCombo* Combo = GTK_COMBO(s->pieces[i]);
gtk_signal_handler_block_by_func (GTK_OBJECT (GTK_COMBO (s->pieces[i])->entry),
GTK_SIGNAL_FUNC (minifigdlg_piece_changed), NULL);
gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (s->pieces[i])->entry), s->wizard->mSettings[i][index].Description);
gtk_list_select_item (GTK_LIST (GTK_COMBO (s->pieces[i])->list), index);
gtk_signal_handler_unblock_by_func (GTK_OBJECT (GTK_COMBO (s->pieces[i])->entry),
GTK_SIGNAL_FUNC (minifigdlg_piece_changed), NULL);
}
gtk_signal_handler_block_by_func(GTK_OBJECT(Combo->entry), GTK_SIGNAL_FUNC(minifigdlg_piece_changed), NULL);
gtk_entry_set_text(GTK_ENTRY(Combo->entry), s->wizard->mSettings[i][index].Description);
gtk_list_select_item(GTK_LIST(Combo->list), index);
gtk_signal_handler_unblock_by_func(GTK_OBJECT(Combo->entry), GTK_SIGNAL_FUNC(minifigdlg_piece_changed), NULL);
}
}
static void minifigdlg_load (GtkWidget *widget, gpointer data)
static void minifigdlg_load(GtkWidget *widget, gpointer data)
{
LC_MINIFIGDLG_STRUCT* s = (LC_MINIFIGDLG_STRUCT*)data;
if (s->wizard->LoadMinifig (gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (s->combo)->entry))) == false)
return;
LC_MINIFIGDLG_STRUCT* s = (LC_MINIFIGDLG_STRUCT*)data;
if (s->wizard->LoadMinifig(gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(s->combo)->entry))) == false)
return;
for (int i = 0; i < LC_MFW_NUMITEMS; i++)
{
set_button_pixmap2(s->colors[i], gColorList[s->wizard->m_Colors[i]].Value);
if (s->angles[i] != NULL)
gtk_spin_button_set_value (GTK_SPIN_BUTTON (s->angles[i]), s->wizard->m_Angles[i]);
}
minifigdlg_updateselection (s);
s->wizard->Redraw ();
for (int i = 0; i < LC_MFW_NUMITEMS; i++)
{
set_button_pixmap2(s->colors[i], gColorList[s->wizard->m_Colors[i]].Value);
if (s->angles[i] != NULL)
gtk_spin_button_set_value(GTK_SPIN_BUTTON(s->angles[i]), s->wizard->m_Angles[i]);
}
minifigdlg_updateselection(s);
s->wizard->Redraw();
}
static void minifigdlg_save (GtkWidget *widget, gpointer data)
static void minifigdlg_save(GtkWidget *widget, gpointer data)
{
LC_MINIFIGDLG_STRUCT* s = (LC_MINIFIGDLG_STRUCT*)data;
s->wizard->SaveMinifig (gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (s->combo)->entry)));
minifigdlg_updatecombo (s);
LC_MINIFIGDLG_STRUCT* s = (LC_MINIFIGDLG_STRUCT*)data;
s->wizard->SaveMinifig(gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(s->combo)->entry)));
minifigdlg_updatecombo(s);
}
static void minifigdlg_delete (GtkWidget *widget, gpointer data)
static void minifigdlg_delete(GtkWidget *widget, gpointer data)
{
LC_MINIFIGDLG_STRUCT* s = (LC_MINIFIGDLG_STRUCT*)data;
s->wizard->DeleteMinifig (gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (s->combo)->entry)));
minifigdlg_updatecombo (s);
LC_MINIFIGDLG_STRUCT* s = (LC_MINIFIGDLG_STRUCT*)data;
s->wizard->DeleteMinifig(gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(s->combo)->entry)));
minifigdlg_updatecombo(s);
}
static void adj_changed (GtkAdjustment *adj, gpointer data)
static void adj_changed(GtkAdjustment *adj, gpointer data)
{
LC_MINIFIGDLG_STRUCT* info = (LC_MINIFIGDLG_STRUCT*)data;
float val;
int i;
LC_MINIFIGDLG_STRUCT* info = (LC_MINIFIGDLG_STRUCT*)data;
float val;
int i;
for (i = 0; i < LC_MFW_NUMITEMS; i++)
if (info->angles[i] != NULL)
if (gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (info->angles[i])) == adj)
break;
for (i = 0; i < LC_MFW_NUMITEMS; i++)
if (info->angles[i] != NULL)
if (gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(info->angles[i])) == adj)
break;
if (i == LC_MFW_NUMITEMS)
return;
if (i == LC_MFW_NUMITEMS)
return;
val = gtk_spin_button_get_value_as_float (GTK_SPIN_BUTTON (info->angles[i]));
val = gtk_spin_button_get_value_as_float(GTK_SPIN_BUTTON(info->angles[i]));
if (val == info->wizard->m_Angles[i])
return;
if (val == info->wizard->m_Angles[i])
return;
info->wizard->SetAngle (i, val);
info->wizard->SetAngle(i, val);
if (info->preview != NULL)
info->wizard->Redraw ();
if (info->preview != NULL)
info->wizard->Redraw();
}
// Create a combo box with a color selection control
static void minifigdlg_createpair (LC_MINIFIGDLG_STRUCT* info, int idx, int num, GtkWidget* table)
static void minifigdlg_createpair(LC_MINIFIGDLG_STRUCT* info, int idx, int num, GtkWidget* table)
{
GtkWidget *combo, *color, *spin;
GtkObject *adj;
GtkWidget *combo, *color, *spin;
GtkObject *adj;
combo = info->pieces[num] = gtk_combo_new ();
gtk_widget_show (combo);
gtk_table_attach (GTK_TABLE (table), combo, 0, 1, idx, idx+1,
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) GTK_EXPAND, 0, 0);
gtk_widget_set_usize (combo, 60, 25);
gtk_entry_set_editable (GTK_ENTRY (GTK_COMBO (combo)->entry), FALSE);
gtk_signal_connect (GTK_OBJECT (GTK_COMBO (combo)->entry), "changed",
GTK_SIGNAL_FUNC (minifigdlg_piece_changed), NULL);
gtk_object_set_data (GTK_OBJECT (GTK_COMBO (combo)->entry), "info", info);
combo = info->pieces[num] = gtk_combo_new();
gtk_widget_show(combo);
gtk_table_attach(GTK_TABLE(table), combo, 0, 1, idx, idx+1,
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) GTK_EXPAND, 0, 0);
gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(combo)->entry), FALSE);
gtk_signal_connect(GTK_OBJECT(GTK_COMBO(combo)->entry), "changed", GTK_SIGNAL_FUNC(minifigdlg_piece_changed), NULL);
gtk_object_set_data(GTK_OBJECT(GTK_COMBO(combo)->entry), "info", info);
color = info->colors[num] = gtk_button_new_with_label ("");
gtk_widget_set_events (color, GDK_EXPOSURE_MASK);
gtk_widget_show (color);
gtk_object_set_data (GTK_OBJECT (color), "color", &info->wizard->m_Colors[num]);
gtk_object_set_data (GTK_OBJECT (color), "info", info);
gtk_widget_set_usize (color, 40, 25);
gtk_signal_connect (GTK_OBJECT (color), "clicked",
GTK_SIGNAL_FUNC (minifigdlg_color_clicked), info);
gtk_table_attach (GTK_TABLE (table), color, 1, 2, idx, idx+1,
(GtkAttachOptions) GTK_FILL, (GtkAttachOptions) GTK_EXPAND, 0, 0);
color = info->colors[num] = gtk_button_new_with_label("");
gtk_widget_set_events(color, GDK_EXPOSURE_MASK);
gtk_widget_show(color);
gtk_object_set_data(GTK_OBJECT(color), "color", &info->wizard->m_Colors[num]);
gtk_object_set_data(GTK_OBJECT(color), "info", info);
gtk_widget_set_usize(color, 40, 25);
gtk_signal_connect(GTK_OBJECT(color), "clicked", GTK_SIGNAL_FUNC(minifigdlg_color_clicked), info);
gtk_table_attach(GTK_TABLE(table), color, 1, 2, idx, idx+1, (GtkAttachOptions) GTK_FILL, (GtkAttachOptions) GTK_EXPAND, 0, 0);
if ((num == LC_MFW_TORSO) || (num == LC_MFW_HIPS))
{
info->angles[num] = NULL;
return;
}
if ((num == LC_MFW_TORSO) || (num == LC_MFW_HIPS))
{
info->angles[num] = NULL;
return;
}
adj = gtk_adjustment_new (0, -180, 180, 1, 10, 0);
gtk_signal_connect (adj, "value_changed", GTK_SIGNAL_FUNC (adj_changed), info);
adj = gtk_adjustment_new(0, -180, 180, 1, 10, 0);
gtk_signal_connect(adj, "value_changed", GTK_SIGNAL_FUNC(adj_changed), info);
spin = info->angles[num] = gtk_spin_button_new (GTK_ADJUSTMENT (adj), 1, 0);
gtk_widget_show (spin);
gtk_object_set_data (GTK_OBJECT (color), "info", info);
// gtk_widget_set_usize (spin, 40, -1);
gtk_table_attach (GTK_TABLE (table), spin, 2, 3, idx, idx+1,
(GtkAttachOptions) GTK_FILL, (GtkAttachOptions) GTK_EXPAND, 0, 0);
gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (spin), TRUE);
spin = info->angles[num] = gtk_spin_button_new(GTK_ADJUSTMENT(adj), 1, 0);
gtk_widget_show(spin);
gtk_object_set_data(GTK_OBJECT(color), "info", info);
gtk_table_attach(GTK_TABLE(table), spin, 2, 3, idx, idx+1, (GtkAttachOptions) GTK_FILL, (GtkAttachOptions) GTK_EXPAND, 0, 0);
gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(spin), TRUE);
gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(spin), TRUE);
gtk_entry_set_width_chars(GTK_ENTRY(spin), 4);
}
int minifigdlg_execute (void* param)
int minifigdlg_execute(void* param)
{
GtkWidget *vbox, *hbox, *frame, *table;
GtkWidget *dlg, *button;
LC_MINIFIGDLG_STRUCT s;
int i;
GtkWidget *vbox, *hbox, *frame, *table;
GtkWidget *dlg, *button;
LC_MINIFIGDLG_STRUCT s;
int i;
int ret;
memset (&s, 0, sizeof (s));
s.wizard = (MinifigWizard*)param;
memset(&s, 0, sizeof(s));
s.wizard = (MinifigWizard*)param;
dlg = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_transient_for (GTK_WINDOW (dlg), GTK_WINDOW (((GtkWidget*)(*main_window))));
gtk_signal_connect (GTK_OBJECT (dlg), "delete_event",
GTK_SIGNAL_FUNC (dlg_delete_callback), NULL);
gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);
gtk_widget_set_usize (dlg, 600, 360);
gtk_window_set_title (GTK_WINDOW (dlg), "Minifig Wizard");
// gtk_window_set_policy (GTK_WINDOW (dlg), FALSE, FALSE, FALSE);
gtk_widget_realize (dlg);
dlg = gtk_dialog_new_with_buttons("Minifig Wizard", GTK_WINDOW(((GtkWidget*)(*main_window))),
(GtkDialogFlags)(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
GTK_STOCK_OK, GTK_RESPONSE_OK, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL);
gtk_container_set_border_width(GTK_CONTAINER(dlg), 5);
gtk_widget_realize(dlg);
s.dlg = dlg;
vbox = gtk_vbox_new (FALSE, 10);
gtk_widget_show (vbox);
gtk_container_add (GTK_CONTAINER (dlg), vbox);
gtk_container_border_width (GTK_CONTAINER (vbox), 5);
vbox = GTK_DIALOG(dlg)->vbox;
gtk_box_set_spacing(GTK_BOX(vbox), 10);
hbox = gtk_hbox_new (FALSE, 5);
gtk_widget_show (hbox);
gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
hbox = gtk_hbox_new(FALSE, 5);
gtk_widget_show(hbox);
gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
table = gtk_table_new (8, 3, FALSE);
gtk_widget_show (table);
gtk_box_pack_start (GTK_BOX (hbox), table, TRUE, TRUE, 0);
gtk_table_set_col_spacings (GTK_TABLE (table), 5);
gtk_table_set_row_spacings (GTK_TABLE (table), 5);
table = gtk_table_new(8, 3, FALSE);
gtk_widget_show(table);
gtk_box_pack_start(GTK_BOX(hbox), table, TRUE, TRUE, 0);
gtk_table_set_col_spacings(GTK_TABLE(table), 5);
gtk_table_set_row_spacings(GTK_TABLE(table), 5);
minifigdlg_createpair (&s, 0, LC_MFW_HAT, table);
minifigdlg_createpair (&s, 1, LC_MFW_NECK, table);
minifigdlg_createpair (&s, 2, LC_MFW_RIGHT_ARM, table);
minifigdlg_createpair (&s, 3, LC_MFW_RIGHT_HAND, table);
minifigdlg_createpair (&s, 4, LC_MFW_RIGHT_TOOL, table);
minifigdlg_createpair (&s, 5, LC_MFW_HIPS, table);
minifigdlg_createpair (&s, 6, LC_MFW_RIGHT_LEG, table);
minifigdlg_createpair (&s, 7, LC_MFW_RIGHT_SHOE, table);
minifigdlg_createpair(&s, 0, LC_MFW_HAT, table);
minifigdlg_createpair(&s, 1, LC_MFW_NECK, table);
minifigdlg_createpair(&s, 2, LC_MFW_RIGHT_ARM, table);
minifigdlg_createpair(&s, 3, LC_MFW_RIGHT_HAND, table);
minifigdlg_createpair(&s, 4, LC_MFW_RIGHT_TOOL, table);
minifigdlg_createpair(&s, 5, LC_MFW_HIPS, table);
minifigdlg_createpair(&s, 6, LC_MFW_RIGHT_LEG, table);
minifigdlg_createpair(&s, 7, LC_MFW_RIGHT_SHOE, table);
s.wizard->CreateFromWindow (&s.preview);
s.wizard->CreateFromWindow(&s.preview);
frame = gtk_frame_new (NULL);
gtk_widget_show (frame);
gtk_container_add (GTK_CONTAINER (hbox), frame);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
frame = gtk_frame_new(NULL);
gtk_widget_show(frame);
gtk_container_add(GTK_CONTAINER(hbox), frame);
gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);
gtk_widget_set_usize (GTK_WIDGET (s.preview), 150, 300);
gtk_container_add (GTK_CONTAINER (frame), GTK_WIDGET (s.preview));
gtk_widget_show (GTK_WIDGET (s.preview));
gtk_object_set_data (GTK_OBJECT (s.preview), "minifig", &s);
gtk_widget_set_usize(GTK_WIDGET(s.preview), 150, 300);
gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(s.preview));
gtk_widget_show(GTK_WIDGET(s.preview));
gtk_object_set_data(GTK_OBJECT(s.preview), "minifig", &s);
table = gtk_table_new (7, 3, FALSE);
gtk_widget_show (table);
gtk_box_pack_start (GTK_BOX (hbox), table, TRUE, TRUE, 0);
gtk_table_set_col_spacings (GTK_TABLE (table), 5);
gtk_table_set_row_spacings (GTK_TABLE (table), 5);
table = gtk_table_new(7, 3, FALSE);
gtk_widget_show(table);
gtk_box_pack_start(GTK_BOX(hbox), table, TRUE, TRUE, 0);
gtk_table_set_col_spacings(GTK_TABLE(table), 5);
gtk_table_set_row_spacings(GTK_TABLE(table), 5);
minifigdlg_createpair (&s, 0, LC_MFW_HEAD, table);
minifigdlg_createpair (&s, 1, LC_MFW_TORSO, table);
minifigdlg_createpair (&s, 2, LC_MFW_LEFT_ARM, table);
minifigdlg_createpair (&s, 3, LC_MFW_LEFT_HAND, table);
minifigdlg_createpair (&s, 4, LC_MFW_LEFT_TOOL, table);
minifigdlg_createpair (&s, 5, LC_MFW_LEFT_LEG, table);
minifigdlg_createpair (&s, 6, LC_MFW_LEFT_SHOE, table);
minifigdlg_createpair(&s, 0, LC_MFW_HEAD, table);
minifigdlg_createpair(&s, 1, LC_MFW_TORSO, table);
minifigdlg_createpair(&s, 2, LC_MFW_LEFT_ARM, table);
minifigdlg_createpair(&s, 3, LC_MFW_LEFT_HAND, table);
minifigdlg_createpair(&s, 4, LC_MFW_LEFT_TOOL, table);
minifigdlg_createpair(&s, 5, LC_MFW_LEFT_LEG, table);
minifigdlg_createpair(&s, 6, LC_MFW_LEFT_SHOE, table);
hbox = gtk_hbox_new (FALSE, 10);
gtk_widget_show (hbox);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
hbox = gtk_hbox_new(FALSE, 10);
gtk_widget_show(hbox);
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
gtk_container_set_border_width(GTK_CONTAINER(hbox), 5);
s.combo = gtk_combo_new ();
gtk_widget_show (s.combo);
gtk_box_pack_start (GTK_BOX (hbox), s.combo, FALSE, TRUE, 0);
gtk_signal_connect (GTK_OBJECT (GTK_COMBO (s.combo)->entry), "changed",
GTK_SIGNAL_FUNC (minifigdlg_load), &s);
s.combo = gtk_combo_new();
gtk_widget_show(s.combo);
gtk_box_pack_start(GTK_BOX(hbox), s.combo, FALSE, TRUE, 0);
gtk_signal_connect(GTK_OBJECT(GTK_COMBO(s.combo)->entry), "changed", GTK_SIGNAL_FUNC(minifigdlg_load), &s);
button = gtk_button_new_with_label ("Save");
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (minifigdlg_save), &s);
gtk_widget_show (button);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, TRUE, 0);
gtk_widget_set_usize (button, 70, 25);
button = gtk_button_new_with_label("Save");
gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(minifigdlg_save), &s);
gtk_widget_show(button);
gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, TRUE, 0);
button = gtk_button_new_with_label ("Delete");
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (minifigdlg_delete), &s);
gtk_widget_show (button);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, TRUE, 0);
gtk_widget_set_usize (button, 70, 25);
button = gtk_button_new_with_label("Delete");
gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(minifigdlg_delete), &s);
gtk_widget_show(button);
gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, TRUE, 0);
button = gtk_button_new_with_label ("OK");
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (minifigdlg_ok), &s);
gtk_widget_show (button);
gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, TRUE, 0);
gtk_widget_set_usize (button, 70, 25);
GtkAccelGroup *accel_group = gtk_accel_group_new ();
gtk_window_add_accel_group (GTK_WINDOW (dlg), accel_group);
gtk_widget_add_accelerator (button, "clicked", accel_group,
GDK_Return, (GdkModifierType)0, GTK_ACCEL_VISIBLE);
// Fill the combo boxes with the available pieces
for (i = 0; i < LC_MFW_NUMITEMS; i++)
{
GList* names = NULL;
int count = s.wizard->mSettings[i].GetSize();
button = gtk_button_new_with_label ("Cancel");
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (dlg_default_callback), GINT_TO_POINTER (LC_CANCEL));
gtk_widget_show (button);
gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, TRUE, 0);
gtk_widget_set_usize (button, 70, 25);
gtk_widget_add_accelerator (button, "clicked", accel_group,
GDK_Escape, (GdkModifierType)0, GTK_ACCEL_VISIBLE);
for (int j = 0; j < count; j++)
names = g_list_append(names, s.wizard->mSettings[i][j].Description);
// Fill the combo boxes with the available pieces
for (i = 0; i < LC_MFW_NUMITEMS; i++)
{
GList* names = NULL;
int count = s.wizard->mSettings[i].GetSize();
if (names != NULL)
{
gtk_signal_handler_block_by_func(GTK_OBJECT(GTK_COMBO(s.pieces[i])->entry), GTK_SIGNAL_FUNC(minifigdlg_piece_changed), NULL);
gtk_combo_set_popdown_strings(GTK_COMBO(s.pieces[i]), names);
g_list_free(names);
gtk_signal_handler_unblock_by_func(GTK_OBJECT(GTK_COMBO(s.pieces[i])->entry), GTK_SIGNAL_FUNC(minifigdlg_piece_changed), NULL);
}
}
for (int j = 0; j < count; j++)
names = g_list_append (names, s.wizard->mSettings[i][j].Description);
minifigdlg_updatecombo(&s);
minifigdlg_updateselection(&s);
if (names != NULL)
{
gtk_signal_handler_block_by_func(GTK_OBJECT(GTK_COMBO(s.pieces[i])->entry),
GTK_SIGNAL_FUNC(minifigdlg_piece_changed), NULL);
gtk_combo_set_popdown_strings (GTK_COMBO (s.pieces[i]), names);
g_list_free (names);
gtk_signal_handler_unblock_by_func(GTK_OBJECT(GTK_COMBO(s.pieces[i])->entry),
GTK_SIGNAL_FUNC(minifigdlg_piece_changed), NULL);
}
}
gtk_widget_show(dlg);
minifigdlg_updatecombo (&s);
minifigdlg_updateselection (&s);
for (i = 0; i < LC_MFW_NUMITEMS; i++)
set_button_pixmap2(s.colors[i], gColorList[s.wizard->m_Colors[i]].Value);
gtk_widget_show(dlg);
if (gtk_dialog_run(GTK_DIALOG(dlg)) == GTK_RESPONSE_OK)
{
ret = LC_OK;
}
else
ret = LC_CANCEL;
for (i = 0; i < LC_MFW_NUMITEMS; i++)
{
set_button_pixmap2(s.colors[i], gColorList[s.wizard->m_Colors[i]].Value);
}
gtk_widget_destroy(dlg);
return dlg_domodal(dlg, LC_CANCEL);
return ret;
}