BOOL CPrintProgressDialog::OnInitDialog() { CDialog::OnInitDialog(); CRect clientRect; GetClientRect(&clientRect); CRect titleRect; GetLocalRect(GetDlgItem(IDC_PPD_DOC_TITLE_STATIC), titleRect, this); CRect itemRect; GetLocalRect(GetDlgItem(IDC_PPD_DOC_TXT), itemRect, this); CRect progRect; progRect.left = titleRect.left; progRect.top = itemRect.top+itemRect.Height()+5; progRect.right = clientRect.Width()-(2*titleRect.left); progRect.bottom = progRect.top+titleRect.Height(); m_wndProgress.Create (WS_CHILD | WS_VISIBLE, progRect, this, -1); m_wndProgress.SetPos (0); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
//Moves accordingly to the mouse void GuiItem::Move() { iPoint tmp = App->input->GetMousePosition(); tmp.x -= GetLocalRect().w / 2; tmp.y -= GetLocalRect().h / 2; SetLocalPosition(tmp); }
//Moves accordingly to the mouse void GuiItem::Move() { //TODO 4: Fill Move() function so, the item movement is exactly like the cursor (hint: not using the draggable property or mouse motion) //and also make that the item is centered at the cursor (is at the middle not at the vertex) iPoint tmp = App->input->GetMousePosition(); tmp.x -= GetLocalRect().w / 2; tmp.y -= GetLocalRect().h / 2; SetLocalPosition(tmp); }
void GuiElement::Center(bool x, bool y) { if (x || y) { int fw, fh; if (parent) { fw = parent->GetLocalRect().w; fh = parent->GetLocalRect().h; } else { fw = App->render->camera.w; fh = App->render->camera.h; } int w, h; SDL_Rect rect = GetLocalRect(); if (x) w = fw / 2 - rect.w / 2; else w = rect.x; if (y) h = fh / 2 - rect.h / 2; else h = rect.y; SetLocalPosition({ w, h }); } }
//-------------------------------------------------------- // Special Hook Procedure for handling the print dialog messages static UINT CALLBACK PrintHookProc(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam) { if (uiMsg == WM_COMMAND) { UINT id = LOWORD(wParam); if (id == rad4 || id == rad5 || id == rad6) { gFrameSelectedRadioBtn = id; SetRadioOfGroup(hdlg, id); } } else if (uiMsg == WM_INITDIALOG) { PRINTDLG * printDlg = (PRINTDLG *)lParam; if (printDlg == nullptr) return 0L; int16_t howToEnableFrameUI = (int16_t)printDlg->lCustData; // don't add frame options if they would be disabled anyway // because there are no frames if (howToEnableFrameUI == nsIPrintSettings::kFrameEnableNone) return TRUE; HINSTANCE hInst = (HINSTANCE)::GetWindowLongPtr(hdlg, GWLP_HINSTANCE); if (hInst == nullptr) return 0L; // Start by getting the local rects of several of the controls // so we can calculate where the new controls are HWND wnd = ::GetDlgItem(hdlg, grp1); if (wnd == nullptr) return 0L; RECT dlgRect; GetLocalRect(wnd, dlgRect, hdlg); wnd = ::GetDlgItem(hdlg, rad1); // this is the top control "All" if (wnd == nullptr) return 0L; RECT rad1Rect; GetLocalRect(wnd, rad1Rect, hdlg); wnd = ::GetDlgItem(hdlg, rad2); // this is the bottom control "Selection" if (wnd == nullptr) return 0L; RECT rad2Rect; GetLocalRect(wnd, rad2Rect, hdlg); wnd = ::GetDlgItem(hdlg, rad3); // this is the middle control "Pages" if (wnd == nullptr) return 0L; RECT rad3Rect; GetLocalRect(wnd, rad3Rect, hdlg); HWND okWnd = ::GetDlgItem(hdlg, IDOK); if (okWnd == nullptr) return 0L; RECT okRect; GetLocalRect(okWnd, okRect, hdlg); wnd = ::GetDlgItem(hdlg, grp4); // this is the "Print range" groupbox if (wnd == nullptr) return 0L; RECT prtRect; GetLocalRect(wnd, prtRect, hdlg); // calculate various different "gaps" for layout purposes int rbGap = rad3Rect.top - rad1Rect.bottom; // gap between radiobtns int grpBotGap = dlgRect.bottom - rad2Rect.bottom; // gap from bottom rb to bottom of grpbox int grpGap = dlgRect.top - prtRect.bottom ; // gap between group boxes int top = dlgRect.bottom + grpGap; int radHgt = rad1Rect.bottom - rad1Rect.top + 1; // top of new group box int y = top+(rad1Rect.top-dlgRect.top); // starting pos of first radio int rbWidth = dlgRect.right - rad1Rect.left - 5; // measure from rb left to the edge of the groupbox // (5 is arbitrary) nsIntRect rect; // Create and position the radio buttons // // If any one control cannot be created then // hide the others and bail out // rect.SetRect(rad1Rect.left, y, rbWidth,radHgt); HWND rad4Wnd = CreateRadioBtn(hInst, hdlg, rad4, kAsLaidOutOnScreenStr, rect); if (rad4Wnd == nullptr) return 0L; y += radHgt + rbGap; rect.SetRect(rad1Rect.left, y, rbWidth, radHgt); HWND rad5Wnd = CreateRadioBtn(hInst, hdlg, rad5, kTheSelectedFrameStr, rect); if (rad5Wnd == nullptr) { Show(rad4Wnd, FALSE); // hide return 0L; } y += radHgt + rbGap; rect.SetRect(rad1Rect.left, y, rbWidth, radHgt); HWND rad6Wnd = CreateRadioBtn(hInst, hdlg, rad6, kEachFrameSeparately, rect); if (rad6Wnd == nullptr) { Show(rad4Wnd, FALSE); // hide Show(rad5Wnd, FALSE); // hide return 0L; } y += radHgt + grpBotGap; // Create and position the group box rect.SetRect (dlgRect.left, top, dlgRect.right-dlgRect.left+1, y-top+1); HWND grpBoxWnd = CreateGroupBox(hInst, hdlg, grp3, NS_LITERAL_STRING("Print Frame"), rect); if (grpBoxWnd == nullptr) { Show(rad4Wnd, FALSE); // hide Show(rad5Wnd, FALSE); // hide Show(rad6Wnd, FALSE); // hide return 0L; } // Here we figure out the old height of the dlg // then figure its gap from the old grpbx to the bottom // then size the dlg RECT pr, cr; ::GetWindowRect(hdlg, &pr); ::GetClientRect(hdlg, &cr); int dlgHgt = (cr.bottom - cr.top) + 1; int bottomGap = dlgHgt - okRect.bottom; pr.bottom += (dlgRect.bottom-dlgRect.top) + grpGap + 1 - (dlgHgt-dlgRect.bottom) + bottomGap; ::SetWindowPos(hdlg, nullptr, pr.left, pr.top, pr.right-pr.left+1, pr.bottom-pr.top+1, SWP_NOMOVE|SWP_NOREDRAW|SWP_NOZORDER); // figure out the new height of the dialog ::GetClientRect(hdlg, &cr); dlgHgt = (cr.bottom - cr.top) + 1; // Reposition the OK and Cancel btns int okHgt = okRect.bottom - okRect.top + 1; ::SetWindowPos(okWnd, nullptr, okRect.left, dlgHgt-bottomGap-okHgt, 0, 0, SWP_NOSIZE|SWP_NOREDRAW|SWP_NOZORDER); HWND cancelWnd = ::GetDlgItem(hdlg, IDCANCEL); if (cancelWnd == nullptr) return 0L; RECT cancelRect; GetLocalRect(cancelWnd, cancelRect, hdlg); int cancelHgt = cancelRect.bottom - cancelRect.top + 1; ::SetWindowPos(cancelWnd, nullptr, cancelRect.left, dlgHgt-bottomGap-cancelHgt, 0, 0, SWP_NOSIZE|SWP_NOREDRAW|SWP_NOZORDER); // localize and initialize the groupbox and radiobuttons InitializeExtendedDialog(hdlg, howToEnableFrameUI); // Looks like we were able to extend the dialog gDialogWasExtended = true; return TRUE; } return 0L; }