# define N_(s) s
#endif
-
extern GtkWidget *about;
extern GtkWidget *GUI_Window;
+extern GtkWidget *GUI_Menubar;
+extern GtkWidget *GUI_Timer;
+extern GtkWidget *GUI_Buttonbar;
+extern GtkWidget *GUI_Board;
extern char *programVersion;
extern int errorExitStatus;
extern int fromY;
extern int toX;
extern int toY;
+extern int squareSize,lineGap;
+
+gboolean
+ExposeProc(object, user_data)
+ GtkObject *object;
+ gpointer user_data;
+{
+ /* do resizing to a fixed aspect ratio */
+ GtkRequisition w;
+ int totalh=0,nw,nh;
+ float ratio;
+ int boardWidth,boardHeight,old,new;
+
+ nw=GTK_WIDGET(object)->allocation.width;
+ nh=GTK_WIDGET(object)->allocation.height;
+
+ old=squareSize;
+ squareSize = nw/(BOARD_WIDTH*1.05+0.05);
+
+ if(old!=squareSize)
+ {
+ lineGap = squareSize*0.05;
+
+ boardWidth = lineGap + BOARD_WIDTH * (squareSize + lineGap);
+ boardHeight = lineGap + BOARD_HEIGHT * (squareSize + lineGap);
+
+ /* get the height of the menus, etc. and calculate the aspect ratio */
+ gtk_widget_size_request(GTK_WIDGET(GUI_Menubar), &w);
+ totalh += w.height;
+ gtk_widget_size_request(GTK_WIDGET(GUI_Timer), &w);
+ totalh += w.height;
+ gtk_widget_size_request(GTK_WIDGET(GUI_Buttonbar), &w);
+ totalh += w.height;
+
+ ratio = (totalh+boardHeight)/(boardWidth) ;
+
+ gtk_widget_set_size_request(GTK_WIDGET(GUI_Board),
+ boardWidth,boardHeight);
+
+ GUI_SetAspectRatio(ratio);
+ /* recreate pieces with new size... TODO: keep svg in memory and just recreate pixmap instead of reloading files */
+ CreatePieces();
+ }
+ return FALSE; /* return false, so that other expose events are called too */
+}
void
QuitProc (object, user_data)
<interface>
<requires lib="gtk+" version="2.16"/>
<!-- interface-naming-policy project-wide -->
+ <object class="GtkListStore" id="MoveHistoryStore">
+ <columns>
+ <!-- column-name Move -->
+ <column type="gint"/>
+ <!-- column-name White -->
+ <column type="gchararray"/>
+ <!-- column-name Black -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
+ <object class="GtkDialog" id="MoveHistory">
+ <property name="border_width">5</property>
+ <property name="type_hint">normal</property>
+ <property name="has_separator">False</property>
+ <child internal-child="vbox">
+ <object class="GtkVBox" id="dialog-vbox1">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">2</property>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">automatic</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <child>
+ <object class="GtkTreeView" id="MoveHistoryView">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="model">MoveHistoryStore</property>
+ <property name="headers_clickable">False</property>
+ <property name="enable_search">False</property>
+ <property name="search_column">0</property>
+ <child>
+ <object class="GtkTreeViewColumn" id="Move">
+ <property name="title">Move</property>
+ <child>
+ <object class="GtkCellRendererText" id="MoveNumberRenderer"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="White">
+ <property name="title">White</property>
+ <child>
+ <object class="GtkCellRendererText" id="MoveWhiteRenderer"/>
+ <attributes>
+ <attribute name="text">1</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="Black">
+ <property name="title">Black</property>
+ <child>
+ <object class="GtkCellRendererText" id="MoveBlackRenderer"/>
+ <attributes>
+ <attribute name="text">2</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child internal-child="action_area">
+ <object class="GtkHButtonBox" id="dialog-action_area1">
+ <property name="visible">True</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="CloseButton">
+ <property name="label" translatable="yes">gtk-close</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ <signal name="released" handler="HistoryPopDown"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="0">CloseButton</action-widget>
+ </action-widgets>
+ </object>
<object class="GtkWindow" id="MainWindow">
+ <property name="events">GDK_EXPOSURE_MASK | GDK_STRUCTURE_MASK | GDK_PROPERTY_CHANGE_MASK</property>
<property name="title" translatable="yes">XBoard</property>
<signal name="destroy" handler="QuitProc"/>
+ <signal name="expose_event" handler="ExposeProc"/>
<child>
<object class="GtkAspectFrame" id="Aspectframe">
<property name="visible">True</property>
<property name="yalign">0</property>
<property name="obey_child">False</property>
<child>
- <object class="GtkVBox" id="VBox">
+ <object class="GtkVBox" id="MenuBox">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
</child>
</object>
<packing>
+ <property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<property name="xalign">0.40000000596046448</property>
<property name="stock">gtk-open</property>
</object>
- <object class="GtkListStore" id="MoveHistoryStore">
- <columns>
- <!-- column-name Move -->
- <column type="gint"/>
- <!-- column-name White -->
- <column type="gchararray"/>
- <!-- column-name Black -->
- <column type="gchararray"/>
- </columns>
- </object>
- <object class="GtkDialog" id="MoveHistory">
- <property name="border_width">5</property>
- <property name="type_hint">normal</property>
- <property name="has_separator">False</property>
- <child internal-child="vbox">
- <object class="GtkVBox" id="dialog-vbox1">
- <property name="visible">True</property>
- <property name="orientation">vertical</property>
- <property name="spacing">2</property>
- <child>
- <object class="GtkScrolledWindow" id="scrolledwindow1">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hscrollbar_policy">automatic</property>
- <property name="vscrollbar_policy">automatic</property>
- <child>
- <object class="GtkTreeView" id="MoveHistoryView">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="model">MoveHistoryStore</property>
- <property name="headers_clickable">False</property>
- <property name="enable_search">False</property>
- <property name="search_column">0</property>
- <child>
- <object class="GtkTreeViewColumn" id="Move">
- <property name="title">Move</property>
- <child>
- <object class="GtkCellRendererText" id="MoveNumberRenderer"/>
- <attributes>
- <attribute name="text">0</attribute>
- </attributes>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkTreeViewColumn" id="White">
- <property name="title">White</property>
- <child>
- <object class="GtkCellRendererText" id="MoveWhiteRenderer"/>
- <attributes>
- <attribute name="text">1</attribute>
- </attributes>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkTreeViewColumn" id="Black">
- <property name="title">Black</property>
- <child>
- <object class="GtkCellRendererText" id="MoveBlackRenderer"/>
- <attributes>
- <attribute name="text">2</attribute>
- </attributes>
- </child>
- </object>
- </child>
- </object>
- </child>
- </object>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- <child internal-child="action_area">
- <object class="GtkHButtonBox" id="dialog-action_area1">
- <property name="visible">True</property>
- <property name="layout_style">end</property>
- <child>
- <object class="GtkButton" id="CloseButton">
- <property name="label" translatable="yes">gtk-close</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_stock">True</property>
- <signal name="released" handler="HistoryPopDown"/>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="pack_type">end</property>
- <property name="position">0</property>
- </packing>
- </child>
- </object>
- </child>
- <action-widgets>
- <action-widget response="0">CloseButton</action-widget>
- </action-widgets>
- </object>
</interface>
/* TODO hide button bar if requested */
}
- /*
- * gtk set properties of widgets
- */
-
- /* set board size */
- gtk_widget_set_size_request(GTK_WIDGET(GUI_Board),
- boardWidth,boardHeight);
-
- /* end gtk set properties of widgets */
if (appData.titleInWindow)
{
/* realize window */
gtk_widget_show (GUI_Window);
- /* do resizing to a fixed aspect ratio */
- {
- GtkRequisition w;
- int totalh=boardHeight;
- float ratio;
-
- gtk_widget_size_request(GTK_WIDGET(GUI_Menubar), &w);
- totalh += w.height;
-
- gtk_widget_size_request(GTK_WIDGET(GUI_Timer), &w);
- totalh += w.height;
-
- gtk_widget_size_request(GTK_WIDGET(GUI_Buttonbar), &w);
- totalh += w.height;
-
- ratio = (totalh)/(boardWidth) ;
- GUI_SetAspectRatio(ratio);
- }
-
+ /* recalc boardsize */
CreateGCs();
CreatePieces();
CreatePieceMenus();
void CreatePieces()
{
- /* order of pieces
- WhitePawn, WhiteKnight, WhiteBishop, WhiteRook, WhiteQueen, WhiteKing,
- BlackPawn, BlackKnight, BlackBishop, BlackRook, BlackQueen, BlackKing,
- */
int i;
+ /* free if used
+ for(i=0;i<MAXPIECES;i++)
+ {
+ if(SVGpieces[i])
+ {
+ g_free(SVGpieces[i]);
+ SVGpieces[i]=NULL;
+ }
+ }
+ */
+
+ /* reload these */
+ SVGLightSquare = load_pixbuf("svg/LightSquare.svg",squareSize);
+ SVGDarkSquare = load_pixbuf("svg/DarkSquare.svg",squareSize);
+ SVGNeutralSquare = load_pixbuf("svg/NeutralSquare.svg",squareSize);
+
+
/* get some defaults going */
for(i=WhitePawn; i<DemotePiece+1; i++)
SVGpieces[i] = load_pixbuf("svg/NeutralSquare.svg",squareSize);
-
SVGpieces[WhitePawn] = load_pixbuf("svg/WhitePawn.svg",squareSize);
SVGpieces[WhiteKnight] = load_pixbuf("svg/WhiteKnight.svg",squareSize);
SVGpieces[WhiteBishop] = load_pixbuf("svg/WhiteBishop.svg",squareSize);