bool wxMultiColumnListCtrl::Create(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style) { wxControl::Create(parent, id, pos, size, style); #if wxCHECK_VERSION(2, 8, 0) SetInitialSize(size); #else SetInitialBestSize(size); #endif return true; }
bool wxControl::PalmCreateField(const wxString& label, const wxPoint& pos, const wxSize& size, bool editable, bool underlined, int justification) { FormType* form = (FormType*)GetParentForm(); if(form==NULL) return false; m_label = label; wxCoord x = pos.x == wxDefaultCoord ? 0 : pos.x, y = pos.y == wxDefaultCoord ? 0 : pos.y, w = size.x == wxDefaultCoord ? 1 : size.x, h = size.y == wxDefaultCoord ? 1 : size.y; AdjustForParentClientOrigin(x, y); FieldType *field = FldNewField( (void **)&form, GetId(), x, y, w, h, stdFont, 10, editable, underlined, false, false, (JustificationType)justification, false, false, false ); if(field==NULL) return false; m_palmField = true; SetInitialBestSize(size); SetLabel(label); Show(); return true; }
bool wxControl::PalmCreateControl(int style, const wxString& label, const wxPoint& pos, const wxSize& size, uint8_t groupID) { FormType* form = (FormType*)GetParentForm(); if(form==NULL) return false; wxCoord x = pos.x == wxDefaultCoord ? 0 : pos.x, y = pos.y == wxDefaultCoord ? 0 : pos.y, w = size.x == wxDefaultCoord ? 1 : size.x, h = size.y == wxDefaultCoord ? 1 : size.y; wxWindow *win = this; while(win->GetParent()) { win = win->GetParent(); wxPoint pt(win->GetClientAreaOrigin()); x += pt.x; y += pt.y; } ControlType *control = CtlNewControl( (void **)&form, GetId(), (ControlStyleType)style, wxEmptyString, x, y, w, h, stdFont, groupID, true ); if(control==NULL) return false; m_palmControl = true; SetInitialBestSize(size); SetLabel(label); Show(); return true; }
// constructor void wxKnob::Create (wxWindow* parent, wxWindowID id, int value, int minValue, int maxValue, unsigned int minAngle, unsigned int range, const wxPoint &pos, const wxSize &size, long style, const wxValidator &validator, const wxString &name) { wxControl::Create (parent, id); SetInitialBestSize (size); // SetClientSize (size); m_min = minValue; m_max = maxValue; range %= 360; minAngle %= 360; m_maxAngle = (minAngle + 360 - range) % 360; m_range = range; SetValue (value); }
CtrlRegisterList::CtrlRegisterList(wxWindow* parent, DebugInterface* _cpu) : wxWindow(parent,wxID_ANY,wxDefaultPosition,wxDefaultSize,wxWANTS_CHARS|wxBORDER), cpu(_cpu) { rowHeight = 14; charWidth = 8; category = 0; maxBits = 128; for (int i = 0; i < cpu->getRegisterCategoryCount(); i++) { int count = cpu->getRegisterCount(i); ChangedReg* regs = new ChangedReg[count]; memset(regs,0,sizeof(ChangedReg)*count); changedCategories.push_back(regs); int maxLen = 0; for (int k = 0; k < cpu->getRegisterCount(i); k++) { maxLen = std::max<int>(maxLen,strlen(cpu->getRegisterName(i,k))); } int x = 17+(maxLen+3)*charWidth; startPositions.push_back(x); currentRows.push_back(0); } menu.AppendRadioItem(ID_REGISTERLIST_DISPLAY32, L"Display 32 bit"); menu.AppendRadioItem(ID_REGISTERLIST_DISPLAY64, L"Display 64 bit"); menu.AppendRadioItem(ID_REGISTERLIST_DISPLAY128, L"Display 128 bit"); menu.Check(ID_REGISTERLIST_DISPLAY128,true); menu.Connect(wxEVT_COMMAND_MENU_SELECTED, (wxObjectEventFunction)&CtrlRegisterList::onPopupClick, NULL, this); SetDoubleBuffered(true); SetInitialBestSize(ClientToWindowSize(GetMinClientSize())); }
bool wxControl::MSWCreateControl(const wxChar *classname, WXDWORD style, const wxPoint& pos, const wxSize& size, const wxString& label, WXDWORD exstyle) { // if no extended style given, determine it ourselves if ( exstyle == (WXDWORD)-1 ) { exstyle = 0; (void) MSWGetStyle(GetWindowStyle(), &exstyle); } // all controls should have this style style |= WS_CHILD; // create the control visible if it's currently shown for wxWidgets if ( m_isShown ) { style |= WS_VISIBLE; } // choose the position for the control: we have a problem with default size // here as we can't calculate the best size before the control exists // (DoGetBestSize() may need to use m_hWnd), so just choose the minimal // possible but non 0 size because 0 window width/height result in problems // elsewhere int x = pos.x == wxDefaultCoord ? 0 : pos.x, y = pos.y == wxDefaultCoord ? 0 : pos.y, w = size.x == wxDefaultCoord ? 1 : size.x, h = size.y == wxDefaultCoord ? 1 : size.y; // ... and adjust it to account for a possible parent frames toolbar AdjustForParentClientOrigin(x, y); m_hWnd = (WXHWND)::CreateWindowEx ( exstyle, // extended style classname, // the kind of control to create label, // the window name style, // the window style x, y, w, h, // the window position and size GetHwndOf(GetParent()), // parent (HMENU)GetId(), // child id wxGetInstance(), // app instance NULL // creation parameters ); if ( !m_hWnd ) { #ifdef __WXDEBUG__ wxFAIL_MSG(wxString::Format ( _T("CreateWindowEx(\"%s\", flags=%08x, ex=%08x) failed"), classname, (unsigned int)style, (unsigned int)exstyle )); #endif // __WXDEBUG__ return false; } // install wxWidgets window proc for this window SubclassWin(m_hWnd); // set up fonts and colours InheritAttributes(); if (!m_hasFont) SetFont(GetDefaultAttributes().font); // set the size now if no initial size specified SetInitialBestSize(size); return true; }
//----------------------------------------------------------------------------- // Board //----------------------------------------------------------------------------- Board::Board(wxWindow *pParent, wxWindowID id, long style, VirtualMachineGUI &vm) : wxPanel(pParent, id, wxDefaultPosition, wxDefaultSize, style | wxWANTS_CHARS), _vm(vm), _pElementPressed(NULL), FONT_Key(18, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD), FONT_KeySmall(10, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD), FONT_ModeIndicator(12, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD), PEN_ModeIndicator(wxColour(96, 192, 96)), COLOUR_ModeIndicatorOn(96, 214, 96), COLOUR_ModeIndicatorOff(196, 196, 196), COLOUR_InfoText(255, 255, 255), BRUSH_BoardFocusOn(wxColour(40, 128, 80)), BRUSH_BoardFocusOff(wxColour(50, 144, 96)), BRUSH_BinLED_On(wxColour(255, 64, 64)), BRUSH_BinLED_Off(wxColour(230, 230, 230)), BRUSH_BinLEDBackground(wxColour(255, 255, 255)), PEN_BinLED_On(wxColour(255, 128, 128)), PEN_BinLED_Off(wxColour(255, 255, 255)), PEN_BinLEDBorder(wxColour(196, 220, 196)), BRUSH_NumLED_On(wxColour(255, 64, 64)), BRUSH_NumLED_Off(wxColour(64, 64, 64)), BRUSH_NumLEDBackground(wxColour(32, 32, 32)), PEN_NumLED_On(wxColour(128, 32, 32)), PEN_NumLED_Off(wxColour(32, 32, 32)), PEN_NumLEDBorder(wxColour(96, 128, 96), 2), BRUSH_KeyFocusOn(wxColour(16, 16, 16)), BRUSH_KeyFocusOff(wxColour(92, 92, 92)), COLOUR_KeyText(214, 214, 214), COLOUR_KeyBlightSide(128, 128, 128) { ClearKeyBuff(); SetInitialBestSize(wxSize(480, 240)); const int CX_Key = 50, CY_Key = 40; do { const int CX_NumLED = 55, CY_NumLED = 80; int x = 120, y = 50; NumLED *pNumLED = new NumLED(this, wxRect(x, y, CX_NumLED, CY_NumLED), wxString::Format(wxT("7-seg LED"))); _elementTbl.push_back(pNumLED); _pNumLED = pNumLED; } while (0); do { const int CX_BinLED = 20, CY_BinLED= 16; for (int i = 0; i < CNT_BinLED; i++) { int x = (CNT_BinLED - 1 - i) * 70 + 10, y = 10; BinLED *pBinLED = new BinLED(this, wxRect(x, y, CX_BinLED, CY_BinLED), wxString::Format(wxT("LED%d"), i)); _elementTbl.push_back(pBinLED); _pBinLEDTbl[i] = pBinLED; } } while (0); do { const int CX_ModeIndicator = 80, CY_ModeIndicator = 20; wxRect rc(10, 150, CX_ModeIndicator, CY_ModeIndicator); _pModeIndicatorProgram = new ModeIndicator(this, rc, wxT("Program")); _elementTbl.push_back(_pModeIndicatorProgram); rc.y += 20; _pModeIndicatorRun = new ModeIndicator(this, rc, wxT("Run")); _elementTbl.push_back(_pModeIndicatorRun); rc.y += 20; _pModeIndicatorStep = new ModeIndicator(this, rc, wxT("Step")); _elementTbl.push_back(_pModeIndicatorStep); } while (0); do { static const struct { const wxChar *text; int keyCode; unsigned char value; int type; } tbl[] = { { wxT("C"), 'C', 0xc, Key_Hex::TYPE }, { wxT("D"), 'D', 0xd, Key_Hex::TYPE }, { wxT("E"), 'E', 0xe, Key_Hex::TYPE }, { wxT("F"), 'F', 0xf, Key_Hex::TYPE }, { wxT("A SET"), WXK_BACK, 0x0, Key_ASET::TYPE }, { wxT("8"), '8', 0x8, Key_Hex::TYPE }, { wxT("9"), '9', 0x9, Key_Hex::TYPE }, { wxT("A"), 'A', 0xa, Key_Hex::TYPE }, { wxT("B"), 'B', 0xb, Key_Hex::TYPE }, { wxT("INCR"), WXK_RETURN, 0x0, Key_INCR::TYPE }, { wxT("4"), '4', 0x4, Key_Hex::TYPE }, { wxT("5"), '5', 0x5, Key_Hex::TYPE }, { wxT("6"), '6', 0x6, Key_Hex::TYPE }, { wxT("7"), '7', 0x7, Key_Hex::TYPE }, { wxT("RUN"), 0, 0x0, Key_RUN::TYPE }, { wxT("0"), '0', 0x0, Key_Hex::TYPE }, { wxT("1"), '1', 0x1, Key_Hex::TYPE }, { wxT("2"), '2', 0x2, Key_Hex::TYPE }, { wxT("3"), '3', 0x3, Key_Hex::TYPE }, { wxT("RESET"), WXK_HOME, 0x0, Key_RESET::TYPE }, }; for (int i = 0; i < NUMBEROF(tbl); i++) { int x = (i % 5) * (CX_Key + 4) + 200; int y = (i / 5) * (CY_Key + 4) + 50; wxFont *pFont = (::wxStrlen(tbl[i].text) == 1)? &FONT_Key : &FONT_KeySmall; Key *pKey; if (tbl[i].type == Key_Hex::TYPE) { pKey = new Key_Hex(this, wxRect(x, y, CX_Key, CY_Key), tbl[i].text, tbl[i].keyCode, *pFont, tbl[i].value); } else if (tbl[i].type == Key_ASET::TYPE) { pKey = new Key_ASET(this, wxRect(x, y, CX_Key, CY_Key), tbl[i].text, tbl[i].keyCode, *pFont, tbl[i].value); } else if (tbl[i].type == Key_INCR::TYPE) { pKey = new Key_INCR(this, wxRect(x, y, CX_Key, CY_Key), tbl[i].text, tbl[i].keyCode, *pFont, tbl[i].value); } else if (tbl[i].type == Key_RUN::TYPE) { pKey = new Key_RUN(this, wxRect(x, y, CX_Key, CY_Key), tbl[i].text, tbl[i].keyCode, *pFont, tbl[i].value); } else if (tbl[i].type == Key_RESET::TYPE) { pKey = new Key_RESET(this, wxRect(x, y, CX_Key, CY_Key), tbl[i].text, tbl[i].keyCode, *pFont, tbl[i].value); } _elementTbl.push_back(pKey); } } while (0); SetModeIndicator(vm.GetMode()); }