Commits

billforsternz committed e1ebb53

Add no auto flip to General options
Remove orphaned files CtrlEnhancedList.h .cpp from build

Comments (0)

Files changed (8)

     <ClInclude Include="src\CtrlBox2.h" />
     <ClInclude Include="src\CtrlBoxBookMoves.h" />
     <ClInclude Include="src\CtrlChessTxt.h" />
-    <ClInclude Include="src\CtrlEnhancedList.h" />
     <ClInclude Include="src\DebugPrintf.h" />
     <ClInclude Include="src\EngineDialog.h" />
     <ClInclude Include="src\GameClock.h" />
     <ClCompile Include="src\CtrlBox2.cpp" />
     <ClCompile Include="src\CtrlBoxBookMoves.cpp" />
     <ClCompile Include="src\CtrlChessTxt.cpp" />
-    <ClCompile Include="src\CtrlEnhancedList.cpp" />
     <ClCompile Include="src\EngineDialog.cpp" />
     <ClCompile Include="src\GameClock.cpp" />
     <ClCompile Include="src\GameClockHalf.cpp" />

src/CtrlEnhancedList.cpp

-/****************************************************************************
- * Control - An enhanced wxListCtrl
- *  Enhancements allow keyboard and mousewheel control
- *  Author:  Bill Forster
- *  Licence: See licencing information in ChessPosition.cpp
- *  Copyright 2010, Triple Happy Ltd.  All rights reserved.
- ****************************************************************************/
-#define _CRT_SECURE_NO_DEPRECATE
-#include "CtrlEnhancedList.h"
-#include "DebugPrintf.h"
-
-IMPLEMENT_CLASS( CtrlEnhancedList, wxListCtrl )
-BEGIN_EVENT_TABLE( CtrlEnhancedList, wxListCtrl )
-    EVT_CHAR( CtrlEnhancedList::OnChar )
-    EVT_MOUSEWHEEL( CtrlEnhancedList::OnMouseWheel )
-END_EVENT_TABLE()
-
-void CtrlEnhancedList::OnMouseWheel( wxMouseEvent &event )
-{
-    wxPoint pt( event.GetPosition() );
-    //int x=0,y=0;
-    int rotation = event.GetWheelRotation();
-    //CalcUnscrolledPosition( pt.x, pt.y, &x, &y );
-    DebugPrintf(( "Mouse wheel event; Rotation: %d, delta = %d\n",
-                  rotation, event.GetWheelDelta() ));
-    //event.Skip();
-    //objs.gl->GotoNextGameIdx( rotation>0 );
-    //wxKeyEvent ev(wxEVT_CHAR);
-    //long hndl = (long)GetHandle();
-    bool up = rotation>0;
-    int keyCode  = (up ? WXK_UP : WXK_DOWN);
-    int rawCode  = (up ? 38 : 40);
-    int rawFlags = (up ? 21495809 : 22020097);
-    wxKeyEvent ev( CreateKeyEvent(wxEVT_CHAR,keyCode,rawFlags,rawCode) );
-    /* objs.canvas->lb-> */ GetEventHandler()->ProcessEvent(ev);
-}
-
-void CtrlEnhancedList::OnChar( wxKeyEvent &event )
-{
-    #ifdef __WXMSW__
-    if( event.GetKeyCode() == WXK_UP || event.GetKeyCode() == WXK_DOWN )
-    {
-        // Sorry about this MS Windows specific code. This code was found
-        //  (with the debugger) to be the code ultimately called to handle
-        //  real keystrokes, *after ProcessEvent() fails for real keystrokes*
-        //  When we send fake keystrokes from the mouse wheel handler above
-        //  ProcessEvent() would fail with no backup. So temporary solution
-        //  is to just do what the backup handler would do, in all cases.
-        MSWDefWindowProc( WM_KEYDOWN, event.GetRawKeyCode(), event.GetRawKeyFlags() );
-        // event now handled, so don't call event.Skip() 
-    }
-    else
-    #endif
-        event.Skip();   // Else not handled yet, let system take it
-}
-

src/CtrlEnhancedList.h

-/****************************************************************************
- * Control - An enhanced wxListCtrl
- *  Enhancements allow keyboard and mousewheel control
- *  Author:  Bill Forster
- *  Licence: See licencing information in ChessPosition.cpp
- *  Copyright 2010, Triple Happy Ltd.  All rights reserved.
- ****************************************************************************/
-#ifndef CTRL_ENHANCED_LIST_H
-#define CTRL_ENHANCED_LIST_H
-#include "wx/wx.h"
-#include "wx/listctrl.h"
-
-class CtrlEnhancedList: public wxListCtrl
-{
-    DECLARE_CLASS( CtrlEnhancedList )
-    DECLARE_EVENT_TABLE()
-public:
-    CtrlEnhancedList( wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style )
-        : wxListCtrl( parent, id, pos, size, style )
-    {
-    }
-    void OnMouseWheel( wxMouseEvent &event );
-    void OnChar( wxKeyEvent &event );
-};
-
-#endif // CTRL_ENHANCED_LIST_H
     if( okay )
     {
         bool is_new_game_main = gd.AtEndOfMainLine();
-        if( !objs.canvas->GetNormalOrientation() )
-            objs.canvas->SetNormalOrientation(true);
+        if( !objs.repository->general.m_no_auto_flip )
+        {
+            if( !objs.canvas->GetNormalOrientation() )
+                objs.canvas->SetNormalOrientation(true);
+        }
         objs.canvas->SetMinimumPlaySize();
         glc.Begin( true );
         ChessRules cr;
     if( okay )
     {
         bool is_new_game_main = gd.AtEndOfMainLine();
-        if( objs.canvas->GetNormalOrientation() )
-            objs.canvas->SetNormalOrientation(false);
+        if( !objs.repository->general.m_no_auto_flip )
+        {
+            if( objs.canvas->GetNormalOrientation() )
+                objs.canvas->SetNormalOrientation(false);
+        }
         objs.canvas->SetMinimumPlaySize();
         glc.Begin( false );
         ChessRules cr;
     Atomic begin;
     if( state==HUMAN || state==PONDERING )
     {
-        bool normal = objs.canvas->GetNormalOrientation();
-        objs.canvas->SetNormalOrientation(!normal);
+        if( !objs.repository->general.m_no_auto_flip )
+        {
+            bool normal = objs.canvas->GetNormalOrientation();
+            objs.canvas->SetNormalOrientation(!normal);
+        }
         SetGroomedPosition();
         ChessRules cr;
         string last_move_txt;

src/GeneralDialog.cpp

     box_sizer->Add( straight_to_game_box, 0,
         wxALIGN_CENTER_VERTICAL|wxALL, 5);
 
+    // No auto flip at start of game or on swap sides
+    wxCheckBox* no_auto_flip = new wxCheckBox( this, ID_NO_AUTO_FLIP,
+       wxT("Don't flip board to put human at bottom"), wxDefaultPosition, wxDefaultSize, 0 );
+    no_auto_flip->SetValue( dat.m_no_auto_flip );
+    box_sizer->Add( no_auto_flip, 0,
+        wxALIGN_CENTER_VERTICAL|wxALL, 5);
+
     // A dividing line before the OK and Cancel buttons
     wxStaticLine* line = new wxStaticLine ( this, wxID_STATIC,
         wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
         wxGenericValidator(& dat.m_no_italics));
     FindWindow(ID_STRAIGHT_TO_GAME)->SetValidator(
         wxGenericValidator(& dat.m_straight_to_game));
+    FindWindow(ID_NO_AUTO_FLIP)->SetValidator(
+        wxGenericValidator(& dat.m_no_auto_flip));
 }
 
 // Sets the help text for the dialog controls
     wxString help5 = "Set this to use a larger font in the moves window";
     FindWindow(ID_LARGE_FONT)->SetHelpText(help5);
     FindWindow(ID_LARGE_FONT)->SetToolTip(help5);
+    wxString help6 = "Set this if you don't want the board to automatically flip around when you start a game as black";
+    FindWindow(ID_NO_AUTO_FLIP)->SetHelpText(help6);
+    FindWindow(ID_NO_AUTO_FLIP)->SetToolTip(help6);
 }
 
 
     ID_NO_ITALICS        = 10002,
     ID_STRAIGHT_TO_GAME  = 10003,
     ID_LARGE_FONT        = 10004, 
-    ID_SMALL_BOARD       = 10005
+    ID_SMALL_BOARD       = 10005,
+    ID_NO_AUTO_FLIP      = 10006
 };
 
 // GeneralDialog class declaration
         ReadBool    ("GeneralStraightToGame",             general.m_straight_to_game  );
         ReadBool    ("GeneralUseSmallBoard",              general.m_small_board   );
         ReadBool    ("GeneralUseLargeFont",               general.m_large_font    );
+        ReadBool    ("GeneralNoAutoFlip",                 general.m_no_auto_flip  );
 
         // NonVolatile
         config->Read("NonVolatileX",                      &nv.m_x );
     config->Write("GeneralNoItalics",                 (int)general.m_no_italics       );
     config->Write("GeneralStraightToGame",            (int)general.m_straight_to_game );
     config->Write("GeneralUseSmallBoard",             (int)general.m_small_board  );
-    config->Write("GeneralUseLargeFont",              (int)general.m_large_font  );
+    config->Write("GeneralUseLargeFont",              (int)general.m_large_font   );
+    config->Write("GeneralNoAutoFlip",                (int)general.m_no_auto_flip );
 
     // NonVolatile
     config->Write("NonVolatileX",                     nv.m_x );
     bool        m_straight_to_game;
     bool        m_small_board;
     bool        m_large_font;
+    bool        m_no_auto_flip;
     GeneralConfig()
     {
         m_notation_language  = "KQRNB (English)";
         m_straight_to_game   = false;
         m_small_board        = false;
         m_large_font         = false;
+        m_no_auto_flip       = false;
     }
 };