// HelpScrollView //--------------------------------------------------------------------------- HelpScrollView::HelpScrollView() : SpecialButtonView() { setSearchName("HelpScrollView"); setTitle("Help Information"); setSubTitle(""); setAllowResize(false); setAllowMove(false); moveTo(bodyTextRect.min); resize(bodyTextRect.getSize()); insert("Key"); insert(""); insert(" LMC = Left Mouse Click"); insert(" RMC = Right Mouse Click"); insert(" RMH = Right Mouse Hold"); insert(""); insert(""); insert("Unit Related"); insert(""); insert(" LMC Selects a unit"); insert(" LMH Makes a bouding box for unit selection"); insert(" RMC De-selects all selected units"); insert(" LMC + Ctrl Directs (force/manual) fire of a unit"); insert(" LMC + Shift, LMC + Ctrl Add unit to selected set"); //insert(" Ctrl + [0..9], Shift + [0..9] Define a group of units"); insert(" Shift + [0..9] Define a group of units"); insert(" Alt + [1..0] Recall a group of units"); insert(" [1..0] Cycles through the corresponding group of units"); //insert(" 'E' Select all units on screen"); //insert(" LMC + 'T'............................Track the selected unit"); //insert(" LMC + 'W'............................Set the selected objective's way point"); //insert(" RMH..................................Fast map scroll"); //insert(" X....................................Scatter units"); //insert(" S....................................Stop units"); //insert(" LMC + Ctrl + Alt.....................Escort unit"); insert(""); insert(""); insert("Game Related"); insert(""); insert(" LMC + 'A' Allies with the clicked unit's team"); //insert(" Ctrl + [F1..F5] Bookmark world locations"); //insert(" Alt + [F1..F5] Recall bookmarked world locations"); insert(" F2 In game menus"); insert(""); insert(""); insert("Outpost Related"); insert(""); insert(" 'O' Cycle through your outposts"); insert(" Ctrl + RMC on captured outpost Displays the outpost view"); insert(" Double RMC on captured outpost Displays the outpost view"); //insert(" Alt + RMC on captured outpost........Sets selected outpost's delivery location"); insert(""); insert(""); insert("Chat Related"); insert(""); insert(" Enter Send message to all"); insert(" Ctrl + 'A' Send message to allies"); insert(" Ctrl + 'E' Send message to enemies"); insert(""); insert(""); insert("View Related"); insert(""); insert(" F1 Help View"); insert(" F6 Rank View"); insert(" F7 Chat View"); insert(" F8 Mini Map View"); insert(" TAB Toolbar"); insert(" RMH + mouse movement Moves any view on the screen"); insert(" RMH + [1 - 5] Sets the background drawing mode"); insert(" "); insert(" "); insert("Mini Map View Related"); insert(""); insert(" RMH + [1 - 7] Sets the blending level of the minimap"); insert(" RMH + [+ or -] Scales the size of the minimap"); //insert(" RMH + 'O' Toggles outposts"); insert(" "); insert(" "); insert("System Related"); insert(""); insert(" F9 BMP screen shot"); insert(" Alt + '-' Decrease brightness"); insert(" Alt + '=' Increase brightness"); insert(" Alt + Keypad plus Increase game resolution"); insert(" Alt + Keypad minus Decrease game resolution"); // Define the scrollBar fot this view. //scrollBar = new ScrollBar(VERTICAL, 0, 1, 0, text.getCount()); //if (scrollBar == 0) //{ // throw Exception("ERROR: Unable to allocate the scrollBar."); //} // //iRect clientRect(getClientRect()); //scrollBar->setViewableAmount(clientRect.getSizeY() / (TEXT_GAP_SPACE + CHAR_YPIX) - 1); //scrollBar->setBlockIncrement(1); //add(scrollBar); maxViewableItems = (getClientRect().getSizeY() - (TEXT_GAP_SPACE + CHAR_YPIX)) / (TEXT_GAP_SPACE + CHAR_YPIX) - 1; topViewableItem = 0; iXY size(20, 20); iXY pos(getClientRect().getSizeX() - size.x, 0); upButton.setLabel("+"); upButton.setBounds(iRect(pos, pos + size)); add(&upButton); pos = iXY(getClientRect().getSizeX() - size.x, getClientRect().getSizeY() - size.y); downButton.setLabel("-"); downButton.setBounds(iRect(pos, pos + size)); add(&downButton); } // end HelpScrollView::HelpScrollView
/********************************************************************************* * Process function of dialog */ BOOL CALLBACK DockingCont::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam) { switch (Message) { case WM_NCACTIVATE: { /* Note: lParam to identify the trigger window */ if ((INT)lParam != -1) { ::SendMessage(_hParent, WM_NCACTIVATE, wParam, 0); } break; } case WM_INITDIALOG: { _hContTab = ::GetDlgItem(_hSelf, IDC_TAB_CONT); _hCaption = ::GetDlgItem(_hSelf, IDC_BTN_CAPTION); /* intial subclassing of caption */ ::SetWindowLong(_hCaption, GWL_USERDATA, reinterpret_cast<LONG>(this)); _hDefaultCaptionProc = reinterpret_cast<WNDPROC>(::SetWindowLong(_hCaption, GWL_WNDPROC, reinterpret_cast<LONG>(wndCaptionProc))); /* intial subclassing of tab */ ::SetWindowLong(_hContTab, GWL_USERDATA, reinterpret_cast<LONG>(this)); _hDefaultTabProc = reinterpret_cast<WNDPROC>(::SetWindowLong(_hContTab, GWL_WNDPROC, reinterpret_cast<LONG>(wndTabProc))); /* set min tab width */ ::SendMessage(_hContTab, TCM_SETMINTABWIDTH, 0, (LPARAM)MIN_TABWIDTH); break; } case WM_NCCALCSIZE: case WM_SIZE: { onSize(); break; } case WM_DRAWITEM : { /* draw tab or caption */ if (((DRAWITEMSTRUCT *)lParam)->CtlID == IDC_TAB_CONT) { drawTabItem((DRAWITEMSTRUCT *)lParam); return TRUE; } else { drawCaptionItem((DRAWITEMSTRUCT *)lParam); return TRUE; } break; } case WM_NCLBUTTONDBLCLK : { RECT rcWnd = {0}; RECT rcClient = {0}; POINT pt = {HIWORD(lParam), LOWORD(lParam)}; getWindowRect(rcWnd); getClientRect(rcClient); ClientToScreen(_hSelf, &rcClient); rcWnd.bottom = rcClient.top; /* if in caption */ if ((rcWnd.top < pt.x) && (rcWnd.bottom > pt.x) && (rcWnd.left < pt.y) && (rcWnd.right > pt.y)) { NotifyParent(DMM_DOCKALL); return TRUE; } break; } case WM_SYSCOMMAND : { switch (wParam & 0xfff0) { case SC_MOVE: NotifyParent(DMM_MOVE); return TRUE; default: break; } return FALSE; } case WM_COMMAND : { switch (LOWORD(wParam)) { case IDCANCEL: doClose(); return TRUE; default : break; } break; } default: break; } return FALSE; }
void DockingCont::onSize(void) { TCITEM tcItem = {0}; RECT rc = {0}; RECT rcTemp = {0}; UINT iItemCnt = ::SendMessage(_hContTab, TCM_GETITEMCOUNT, 0, 0); UINT iTabOff = 0; getClientRect(rc); if (iItemCnt >= 1) { /* resize to docked window */ if (_isFloating == false) { /* draw caption */ if (_isTopCaption == TRUE) { ::SetWindowPos(_hCaption, NULL, rc.left, rc.top, rc.right, HIGH_CAPTION, SWP_NOZORDER | SWP_NOACTIVATE); rc.top += HIGH_CAPTION; rc.bottom -= HIGH_CAPTION; } else { ::SetWindowPos(_hCaption, NULL, rc.left, rc.top, HIGH_CAPTION, rc.bottom, SWP_NOZORDER | SWP_NOACTIVATE); rc.left += HIGH_CAPTION; rc.right -= HIGH_CAPTION; } if (iItemCnt >= 2) { /* resize tab and plugin control if tabs exceeds one */ /* resize tab */ rcTemp = rc; rcTemp.top = (rcTemp.bottom + rcTemp.top) - (HIGH_TAB+CAPTION_GAP); rcTemp.bottom = HIGH_TAB; iTabOff = HIGH_TAB; ::SetWindowPos(_hContTab, NULL, rcTemp.left, rcTemp.top, rcTemp.right, rcTemp.bottom, SWP_NOZORDER | SWP_SHOWWINDOW | SWP_NOACTIVATE); } /* resize client area for plugin */ rcTemp = rc; if (_isTopCaption == TRUE) { rcTemp.top += CAPTION_GAP; rcTemp.bottom -= (iTabOff + CAPTION_GAP); } else { rcTemp.left += CAPTION_GAP; rcTemp.right -= CAPTION_GAP; rcTemp.bottom -= iTabOff; } /* set position of client area */ ::SetWindowPos(::GetDlgItem(_hSelf, IDC_CLIENT_TAB), NULL, rcTemp.left, rcTemp.top, rcTemp.right, rcTemp.bottom, SWP_NOZORDER | SWP_NOACTIVATE); } /* resize to float window */ else { /* update floating size */ if (_isFloating == true) { for (size_t iTb = 0; iTb < _vTbData.size(); iTb++) { getWindowRect(_vTbData[iTb]->rcFloat); } } /* draw caption */ if (iItemCnt >= 2) { /* resize tab if size of elements exceeds one */ rcTemp = rc; rcTemp.top = rcTemp.bottom - (HIGH_TAB+CAPTION_GAP); rcTemp.bottom = HIGH_TAB; ::SetWindowPos(_hContTab, NULL, rcTemp.left, rcTemp.top, rcTemp.right, rcTemp.bottom, SWP_NOZORDER | SWP_SHOWWINDOW); } /* resize client area for plugin */ rcTemp = rc; rcTemp.bottom -= ((iItemCnt == 1)?0:HIGH_TAB); ::SetWindowPos(::GetDlgItem(_hSelf, IDC_CLIENT_TAB), NULL, rcTemp.left, rcTemp.top, rcTemp.right, rcTemp.bottom, SWP_NOZORDER | SWP_NOACTIVATE); } /* get active item data */ UINT iItemCnt = ::SendMessage(_hContTab, TCM_GETITEMCOUNT, 0, 0); /* resize visible plugin windows */ for (UINT iItem = 0; iItem < iItemCnt; iItem++) { tcItem.mask = TCIF_PARAM; ::SendMessage(_hContTab, TCM_GETITEM, iItem, (LPARAM)&tcItem); ::SetWindowPos(((tTbData*)tcItem.lParam)->hClient, NULL, 0, 0, rcTemp.right, rcTemp.bottom, SWP_NOZORDER); } } }
// doDraw //--------------------------------------------------------------------------- void MiniMapView::doDraw(const Surface &viewArea, const Surface &clientArea) { assert(this != 0); assert(viewArea.getDoesExist()); assert(clientArea.getDoesExist()); if (decreaseSize != 0) { doDecreaseSize(decreaseSize); decreaseSize = 0; } if (increaseSize != 0) { doIncreaseSize(increaseSize); increaseSize = 0; } float dt = TimerInterface::getTimeSlice(); Surface *miniMap; miniMap = MiniMapInterface::getMiniMap(); if (needScale) { scaleGroupWait += dt; if (scaleGroupWait > 1.0f) { miniMapSurface.create(getViewRect().getSize(), getViewRect().getSize().x , 1); //miniMapSurface.scale(getViewRect().getSize()); iRect r(iXY(0, 0), getViewRect().getSize()); miniMapSurface.bltScale(*miniMap, r); needScale = false; scaleGroupWait = 0.0f; } } iRect r(getViewRect().min, getViewRect().max); if (needScale) { // Draw the slow on the fly scaled map. if (mapDrawType == MAP_SOLID) { clientArea.bltScale(*miniMap, r); } else if (mapDrawType == MAP_2080) { clientArea.bltBlendScale(*miniMap, r, Palette::colorTable2080); } else if (mapDrawType == MAP_4060) { clientArea.bltBlendScale(*miniMap, r, Palette::colorTable4060); } //else if (mapDrawType == MAP_BLEND_GREEN) //{ //clientArea.bltLookup(iRect(iXY(0, 0), getSize()), Palette::green256.getColorArray()); //} else if (mapDrawType == MAP_BLEND_GRAY) { clientArea.bltLookup(iRect(iXY(0, 0), getSize()), Palette::gray256.getColorArray()); } else if (mapDrawType == MAP_BLEND_DARK_GRAY) { clientArea.bltLookup(iRect(iXY(0, 0), getSize()), Palette::darkGray256.getColorArray()); } else if (mapDrawType == MAP_BLACK) { clientArea.fill(Color::black); } else if (mapDrawType == MAP_TRANSPARENT) {} } else { // Draw the fast not on the fly scaled map. if (mapDrawType == MAP_SOLID) { miniMapSurface.blt(clientArea, 0, 0); } else if (mapDrawType == MAP_2080) { clientArea.blendIn(miniMapSurface, iXY(0, 0), Palette::colorTable2080); } else if (mapDrawType == MAP_4060) { clientArea.blendIn(miniMapSurface, iXY(0, 0), Palette::colorTable4060); } //else if (mapDrawType == MAP_BLEND_GREEN) //{ //clientArea.bltLookup(iRect(iXY(0, 0), getSize()), Palette::green256.getColorArray()); //} else if (mapDrawType == MAP_BLEND_GRAY) { clientArea.bltLookup(iRect(iXY(0, 0), getSize()), Palette::gray256.getColorArray()); } else if (mapDrawType == MAP_BLEND_DARK_GRAY) { clientArea.bltLookup(iRect(iXY(0, 0), getSize()), Palette::darkGray256.getColorArray()); } else if (mapDrawType == MAP_BLACK) { clientArea.fill(Color::black); } else if (mapDrawType == MAP_TRANSPARENT) {} } // Draw a hairline border. //viewArea.drawRect(Color::white); viewArea.drawLookupBorder(Palette::darkGray256.getColorArray()); // Draw the world view box. clientArea.bltLookup(MiniMapInterface::getWorldWindow(), Palette::darkGray256.getColorArray()); // Draw the units and such on the minimap. MiniMapInterface::annotateMiniMap((Surface &) clientArea); // Draw the world view box corners. clientArea.drawBoxCorners(MiniMapInterface::getWorldWindow(), 5, Color::white); // Draw an inner black rect inside the outer white rect, for visibility reasons. //iRect innerRect(MiniMapInterface::getWorldWindow()); // //innerRect.min += 1; //innerRect.max -= 1; // //clientArea.drawBoxCorners(innerRect, 4, Color::black); // If the mouse is over the client area, then change the cursor. if (getClientRect().contains(getScreenToClientPos(mouse.getScreenPos()))) { if (selectionAnchor) { // Since we are selecting units, draw the selection box. clientArea.drawRect(selectionAnchorDownPos, selectionAnchorCurPos, Color::white); } else { // Draw a box which show where the area which you click will be located. drawMouseBox(clientArea); } } GameTemplateView::doDraw(viewArea, clientArea); } // end doDraw
int ATOM_CurveEditor::timeValueToCoord (float timeInSecond) const { unsigned canvasSize = (getClientRect().size.w > getCanvasSize().w) ? getClientRect().size.w : getCanvasSize().w; return timeInSecond * _timeAxisUnitResolution + canvasSize * _originTimeAxis - getScrollValue().x; }
void CHexViewView::OnSize(UINT nType, int cx, int cy) { CView::OnSize(nType, cx, cy); createWorkDC(getClientRect(this).Size()); keepSelection().repaint(); }
// VehicleSelectionView //--------------------------------------------------------------------------- VehicleSelectionView::VehicleSelectionView() : GameTemplateView() { setSearchName("VehicleSelectionView"); // setTitle(_("Unit Production")); moveTo(iXY(0, 0)); const int yOffset = 16; const int gapSpace = 1; resizeClientArea(48 * 5 + gapSpace+1 * 4, 198 + 100 + 16); // Power status. iXY pos(0 ,2); pos.x = 0; add( new Label( pos.x+2, pos.y+2, _("Static Display"), Color::white) ); pos.x = getClientRect().getWidth() - 102; if ( !buttonStaticDisplay ) buttonStaticDisplay = new Button(); buttonStaticDisplay->setLabel(_("On")); buttonStaticDisplay->setLocation(pos.x, pos.y); buttonStaticDisplay->setSize( 100, 14); buttonStaticDisplay->setNormalBorder(); add(buttonStaticDisplay); pos.y += yOffset+2; pos.x = 0; add( new Label( pos.x+2, pos.y+2, _("Power"), Color::white) ); pos.x = getClientRect().getWidth() - 102; if ( !buttonPower ) buttonPower = new Button(); buttonPower->setLabel(_("Off")); buttonPower->setLocation(pos.x,pos.y); buttonPower->setSize( 100, 14); buttonPower->setNormalBorder(); add(buttonPower); pos.y += yOffset+5; // XXX hardcoded for now pos.x = 0; add( new Label( pos.x+2, pos.y+2, _("Production"), Color::white) ); productionUnitPos.x = 130; productionUnitPos.y = pos.y + 2; pos.y += yOffset; pos.x = 0; add( new Label( pos.x+2, pos.y+2, _("Time"), Color::white) ); timeRequiredPos.x = productionUnitPos.x; timeRequiredPos.y = pos.y + 2; pos.y += yOffset; pos.x = 0; add( new Label( pos.x+2, pos.y+2, _("Unit Built"), Color::white) ); unitsBuiltPos.x = productionUnitPos.x; unitsBuiltPos.y = pos.y + 2; pos.y += yOffset; pos.x = 0; Surface tempSurface; UnitProfile *uprofile; UnitSelectionButton *usb; if ( ! unitImages.empty() ) { unitImages.deleteAll(); unitImages.clear(); } for ( unsigned ut=0; ut < UnitProfileInterface::getNumUnitTypes(); ut++) { uprofile = UnitProfileInterface::getUnitProfile(ut); Surface * s = new Surface(); s->loadPNG(uprofile->imagefile.c_str()); unitImages.push_back(s); usb = new UnitSelectionButton(this, ut, pos.x, pos.y, *s); add(usb); pos.x += 48 + gapSpace; if ( pos.x+48 > getEndX() ) { pos.x = 0; pos.y += 48 + gapSpace; } } if ( pos.x == 0 ) { pos.y += gapSpace * 3; // and the one just added before = 4 } else { pos.y += 48 + gapSpace * 4; pos.x = 0; } unitProfileDataY = pos.y; pos.y += 73; //addLabel(pos + 2, "Time Remaining:", Color::white); //timeRemainingPos.x = (strlen("Time Remaining: ") + 1) * CHAR_XPIX + 2; //timeRemainingPos.y = pos.y + 2; //pos.y += yOffset; pos.x = (getClientRect().getWidth() - 100) / 2; if ( !buttonOk ) buttonOk = new Button(); buttonOk->setLabel(_("Close")); buttonOk->setLocation(pos.x,pos.y); buttonOk->setSize(100, 14); buttonOk->setNormalBorder(); add(buttonOk); maxHitPoints = 1; maxAttackFactor = 1; maxAttackRange = 1; maxDefendRange = 1; maxTotalSpeed = 1; maxReloadTime = 1; maxRegenTime = 1; getProfileData(); highlightedUnitType = -1; iRect r = getClientRect(); // statusBar = new BoxedLabel(r.getLocationX()+4, r.getEndY() - 32, r.getWidth() - 8, "XXX", Color::black, Color::gray192); // add(statusBar); } // end VehicleSelectionView::VehicleSelectionView
// VehicleSelectionView //--------------------------------------------------------------------------- VehicleSelectionView::VehicleSelectionView() : GameTemplateView() { setSearchName("VehicleSelectionView"); setTitle("Unit Production"); setSubTitle(""); setAllowResize(false); setVisible(false); setBordered(true); setDisplayStatusBar(true); moveTo(iXY(0, 0)); char strBuf[256]; int unit_regen_time; const int yOffset = 15; const int gapSpace = 1; resizeClientArea(48 * 5 + gapSpace * 4, 198 + 84); // Power status. iXY pos(0 ,0); pos.x = 0; addLabel(pos + iXY(2,2), "Static Display:", Color::white); pos.x = getClientRect().getSizeX() - 100; buttonStaticDisplay.setLabel("On"); buttonStaticDisplay.setBounds(iRect(pos, pos + iXY(100, 15))); add(&buttonStaticDisplay); pos.y += yOffset; pos.x = 0; addLabel(pos + iXY(2,2) , "Power:", Color::white); pos.x = getClientRect().getSizeX() - 100; buttonPower.setLabel("Off"); buttonPower.setBounds(iRect(pos, pos + iXY(100, 15))); add(&buttonPower); pos.y += yOffset; // XXX hardcoded for now int CHAR_XPIX = 8; pos.x = 0; addLabel(pos + iXY(2,2), "Production:", Color::white); productionUnitPos.x = (strlen("Current Unit:") + 1) * CHAR_XPIX + 2; productionUnitPos.y = pos.y + 2; pos.y += yOffset; pos.x = 0; addLabel(pos + iXY(2,2), "Time: ", Color::white); timeRequiredPos.x = (strlen("Time: ") + 1) * CHAR_XPIX + 2; timeRequiredPos.y = pos.y + 2; pos.y += yOffset; pos.x = 0; addLabel(pos + iXY(2,2), "Unit Built: ", Color::white); unitsBuiltPos.x = (strlen("Time: ") + 1) * CHAR_XPIX + 2; unitsBuiltPos.y = pos.y + 2; pos.y += yOffset; pos.x = 0; // Unit images. unit_regen_time = getUnitRegenTime(_unit_type_humvee); sprintf(strBuf, "SpahPanzer - Build Time: %01d:%02d", unit_regen_time / 60, unit_regen_time % 60); addButtonBMPBordered(pos, "pics/menus/vehicleSelectionView/scout.bmp", strBuf, bSelectScout); abstractButtonHumvee.setBounds(iRect(pos, pos + iXY(48,48))); add(&abstractButtonHumvee); pos.x += 48 + gapSpace; unit_regen_time = getUnitRegenTime(_unit_type_valentine); sprintf(strBuf, "Manta - Build Time: %01d:%02d", unit_regen_time / 60, unit_regen_time % 60); addButtonBMPBordered(pos, "pics/menus/vehicleSelectionView/manta.bmp", strBuf, bSelectManta); abstractButtonValentine.setBounds(iRect(pos, pos + iXY(48,48))); add(&abstractButtonValentine); pos.x += 48 + gapSpace; unit_regen_time = getUnitRegenTime(_unit_type_leopard); sprintf(strBuf, "Panther1 - Build Time: %01d:%02d", unit_regen_time / 60, unit_regen_time % 60); addButtonBMPBordered(pos, "pics/menus/vehicleSelectionView/panther1.bmp", strBuf, bSelectPanther1); abstractButtonLeopard.setBounds(iRect(pos, pos + iXY(48,48))); add(&abstractButtonLeopard); pos.x += 48 + gapSpace; unit_regen_time = getUnitRegenTime(_unit_type_abrams); sprintf(strBuf, "Titan - Build Time: %01d:%02d", unit_regen_time / 60, unit_regen_time % 60); addButtonBMPBordered(pos, "pics/menus/vehicleSelectionView/titan.bmp", strBuf, bSelectTitan); abstractButtonAbrams.setBounds(iRect(pos, pos + iXY(48,48))); add(&abstractButtonAbrams); pos.x += 48 + gapSpace; unit_regen_time = getUnitRegenTime(_unit_type_hammerhead); sprintf(strBuf, "Stinger - Build Time: %01d:%02d", unit_regen_time / 60, unit_regen_time % 60); addButtonBMPBordered(pos, "pics/menus/vehicleSelectionView/stinger.bmp", strBuf, bSelectStinger); abstractButtonHammerhead.setBounds(iRect(pos, pos + iXY(48,48))); add(&abstractButtonHammerhead); pos.x = 0; pos.y += 48 + gapSpace; unit_regen_time = getUnitRegenTime(_unit_type_lynx); sprintf(strBuf, "Bobcat - Build Time: %01d:%02d", unit_regen_time / 60, unit_regen_time % 60); addButtonBMPBordered(pos, "pics/menus/vehicleSelectionView/bobcat.bmp", strBuf, bSelectBobcat); abstractButtonLynx.setBounds(iRect(pos, pos + iXY(48,48))); add(&abstractButtonLynx); pos.x += 48 + gapSpace; unit_regen_time = getUnitRegenTime(_unit_type_scorpion); sprintf(strBuf, "Wolf - Build Time: %01d:%02d", unit_regen_time / 60, unit_regen_time % 60); addButtonBMPBordered(pos, "pics/menus/vehicleSelectionView/wolf.bmp", strBuf, bSelectWolf); abstractButtonScorpion.setBounds(iRect(pos, pos + iXY(48, 48))); add(&abstractButtonScorpion); pos.x += 48 + gapSpace; unit_regen_time = getUnitRegenTime(_unit_type_spahpanzer); sprintf(strBuf, "Bear - Build Time: %01d:%02d", unit_regen_time / 60, unit_regen_time % 60); addButtonBMPBordered(pos, "pics/menus/vehicleSelectionView/bear.bmp", strBuf, bSelectBear); abstractButtonSpahpanzer.setBounds(iRect(pos, pos + iXY(48, 48))); add(&abstractButtonSpahpanzer); pos.x += 48 + gapSpace; unit_regen_time = getUnitRegenTime(_unit_type_m109); sprintf(strBuf, "Drake - Build Time: %01d:%02d", unit_regen_time / 60, unit_regen_time % 60); addButtonBMPBordered(pos, "pics/menus/vehicleSelectionView/drake.bmp", strBuf, bSelectDrake); abstractButtonM109.setBounds(iRect(pos, pos + iXY(48, 48))); add(&abstractButtonM109); pos.x += 48 + gapSpace; unit_regen_time = getUnitRegenTime(_unit_type_archer); sprintf(strBuf, "Archer - Build Time: %01d:%02d", unit_regen_time / 60, unit_regen_time % 60); addButtonBMPBordered(pos, "pics/menus/vehicleSelectionView/archer.bmp", strBuf, bSelectArcher); abstractButtonArcher.setBounds(iRect(pos, pos + iXY(48, 48))); add(&abstractButtonArcher); pos.y += 48 + gapSpace * 4; pos.x = 0; unitProfileDataY = pos.y; pos.y += 74; //addLabel(pos + 2, "Time Remaining:", Color::white); //timeRemainingPos.x = (strlen("Time Remaining: ") + 1) * CHAR_XPIX + 2; //timeRemainingPos.y = pos.y + 2; //pos.y += yOffset; pos.x = (getClientRect().getSizeX() - 100) / 2; buttonOk.setLabel("Ok"); buttonOk.setBounds(iRect(pos, pos + iXY(100, 15))); add(&buttonOk); unitImages.create(48, 48, _MAX_UNIT_TYPES); Surface tempSurface; int i = 0; tempSurface.loadBMP("pics/menus/vehicleSelectionView/manta.bmp"); unitImages.setFrame(i++); tempSurface.blt(unitImages, 0, 0); tempSurface.loadBMP("pics/menus/vehicleSelectionView/panther1.bmp"); unitImages.setFrame(i++); tempSurface.blt(unitImages, 0, 0); tempSurface.loadBMP("pics/menus/vehicleSelectionView/titan.bmp"); unitImages.setFrame(i++); tempSurface.blt(unitImages, 0, 0); tempSurface.loadBMP("pics/menus/vehicleSelectionView/stinger.bmp"); unitImages.setFrame(i++); tempSurface.blt(unitImages, 0, 0); tempSurface.loadBMP("pics/menus/vehicleSelectionView/bobcat.bmp"); unitImages.setFrame(i++); tempSurface.blt(unitImages, 0, 0); tempSurface.loadBMP("pics/menus/vehicleSelectionView/bear.bmp"); unitImages.setFrame(i++); tempSurface.blt(unitImages, 0, 0); tempSurface.loadBMP("pics/menus/vehicleSelectionView/archer.bmp"); unitImages.setFrame(i++); tempSurface.blt(unitImages, 0, 0); tempSurface.loadBMP("pics/menus/vehicleSelectionView/wolf.bmp"); unitImages.setFrame(i++); tempSurface.blt(unitImages, 0, 0); tempSurface.loadBMP("pics/menus/vehicleSelectionView/drake.bmp"); unitImages.setFrame(i++); tempSurface.blt(unitImages, 0, 0); tempSurface.loadBMP("pics/menus/vehicleSelectionView/scout.bmp"); unitImages.setFrame(i++); tempSurface.blt(unitImages, 0, 0); unitImages.setFrame(i++); unitImages.fill(Color::red); unitImages.setFrame(i++); unitImages.fill(Color::green); unitImages.setFrame(i++); unitImages.fill(Color::blue); maxHitPoints = 1; maxAttackFactor = 1; maxAttackRange = 1; maxDefendRange = 1; maxTotalSpeed = 1; maxReloadTime = 1; maxRegenTime = 1; getProfileData(); highlightedUnitType = 0; } // end VehicleSelectionView::VehicleSelectionView
// LibView //--------------------------------------------------------------------------- LibView::LibView() : GameTemplateView() { setSearchName("LibView"); setTitle("Lib Stats"); setSubTitle(" - F5"); setAllowResize(false); setAllowMove(true); setDisplayStatusBar(false); setVisible(false); moveTo(0, 0); resize(325, 375); addButtonCenterText(iXY((getClientRect().getSize().x / 3) * 0, 0), getClientRect().getSize().x / 3, "Surface", "", bSurfaceInfo); addButtonCenterText(iXY((getClientRect().getSize().x / 3) * 1, 0), getClientRect().getSize().x / 3, "Particles", "", bParticleInfo); addButtonCenterText(iXY((getClientRect().getSize().x / 3) * 2, 0), getClientRect().getSize().x / 3, "Environment", "", bEnvironmentInfo); checkBoxAllowParticleGeneration = new CheckBox(); checkBoxAllowParticleGeneration->setLabel("Allow Particle Generation"); checkBoxAllowParticleGeneration->setLocation(0, 15); checkBoxAllowParticleGeneration->setState(Particle2D::getCreateParticles()); add(checkBoxAllowParticleGeneration); checkBoxAllowTimeSlice = new CheckBox(); checkBoxAllowTimeSlice->setLabel("Allow Time Slice"); checkBoxAllowTimeSlice->setLocation(0, 30); checkBoxAllowTimeSlice->setState(gTimeSliceFlag); add(checkBoxAllowTimeSlice); checkBoxAllowSpanBlitting = new CheckBox(); checkBoxAllowSpanBlitting->setLabel("Allow Blended Span Blitting"); checkBoxAllowSpanBlitting->setLocation(0, 45); checkBoxAllowSpanBlitting->setState(allowSpanBlitting); add(checkBoxAllowSpanBlitting); checkBoxParticlesCanHaveSmoke = new CheckBox(); checkBoxParticlesCanHaveSmoke->setLabel("Allow Explosion Particle Smoke"); checkBoxParticlesCanHaveSmoke->setLocation(0, 60); checkBoxParticlesCanHaveSmoke->setState(ParticleInterface::gParticlesCanHaveSmoke); add(checkBoxParticlesCanHaveSmoke); checkBoxSolidColorExplosionParticles = new CheckBox(); checkBoxSolidColorExplosionParticles->setLabel("Solid Color Explosion Particles"); checkBoxSolidColorExplosionParticles->setLocation(0, 75); checkBoxSolidColorExplosionParticles->setState(ParticleInterface::gSolidColorExplosionParticles); add(checkBoxSolidColorExplosionParticles); checkBoxParticleInterfaceSim = new CheckBox(); checkBoxParticleInterfaceSim->setLabel("Particle Interface Sim"); checkBoxParticleInterfaceSim->setLocation(0, 90); checkBoxParticleInterfaceSim->setState(ParticleInterface::gTestSim); add(checkBoxParticleInterfaceSim); checkBoxSolidBackground = new CheckBox(); checkBoxSolidBackground->setLabel("Solid Background"); checkBoxSolidBackground->setLocation(0, 105); checkBoxSolidBackground->setState(GameView::gDrawSolidBackground); add(checkBoxSolidBackground); checkBoxDrawExplosionParticleCount = new CheckBox(); checkBoxDrawExplosionParticleCount->setLabel("Draw Explosion Particle Count"); checkBoxDrawExplosionParticleCount->setLocation(0, 120); checkBoxDrawExplosionParticleCount->setState(ParticleInterface::gDrawExplosionParticleCount); add(checkBoxDrawExplosionParticleCount); } // end LibView::LibView
// drawHostList //--------------------------------------------------------------------------- void GetSessionHostView::drawHostList(const Surface &dest) { char host_info_str[256]; int curIndex = 0; int color; Surface tempSurface( getClientRect().getSizeX() - 2, (TEXT_GAP_SPACE + CHAR_YPIX), getClientRect().getSizeX() - 2, 1 ); tempSurface.fill(Color::darkGreen); sprintf( host_info_str, "%-24s %-24s %-12s %10s", "Host", "Map", "Game Type", "Players" ); tempSurface.bltString( 4, 1, host_info_str, Color::white ); tempSurface.blt(dest, 0, 1 ); curIndex++; for (int i = 0; i < hosts.getCount(); i++) { sprintf( host_info_str, "%-24s %-24s %-15s %4d/%-4d", hosts[i].name, hosts[i].map, hosts[i].game_type, hosts[i].current_players, hosts[i].max_players ); color = Color::white; if (i == highlightedItem) { color = Color::red; } else if (i == selectedItem) { color = Color::green; } dest.bltString(4, 6 + curIndex * (TEXT_GAP_SPACE + CHAR_YPIX), host_info_str, color); curIndex++; } //for (int i = topViewableItem; i < topViewableItem + maxViewableItems; i++) /* int i; int shit = 0; int color; for (i = scrollBar.getValue(); i < scrollBar.getValue() + viewableItemCount; i++) { iXY offset; offset.x = 2; offset.y = 2 + shit * (CHAR_YPIX + ITEM_GAP_SPACE); // Get a color for the item. if (i == selectedItem) { color = Color::green; } else if (i == highlightedItem) { color = Color::red; } else { color = Color::white; } // Display the name of this shape. dest.bltString(offset.x, offset.y, hosts[i].getName(), color); shit++; } */ } // end GetSessionHostView::drawHostList
void PipeButtonStandard::drawContents(GraphicsPort* port) { // Do not draw if contents not revealed if (!isRevealed()) { drawUnrevealedContents(port); return; } Rect rect; getClientRect(rect); u16 colour; if (isEnabled()) { colour = getShadowColour(); } else { colour = getDarkColour(); } if (hasTopConnector()) { s16 x1 = (rect.width - FLOW_SIZE) / 2; s16 y1 = 0; s16 x2 = x1; s16 y2 = y1 + (rect.height / 2) - 1; port->drawLine(x1, y1, x2, y2, colour); // Draw flow port->drawFilledRect(x1, y1, FLOW_SIZE, getFlowLevel(), woopsiRGB(0, 0, 20)); x1 = (rect.width + FLOW_SIZE) / 2; x2 = x1; port->drawLine(x1, y1, x2, y2, colour); } if (hasBottomConnector()) { s16 x1 = (rect.width - FLOW_SIZE) / 2; s16 y1 = rect.height / 2; s16 x2 = x1; s16 y2 = y1 + (rect.height / 2) - 1; port->drawLine(x1, y1, x2, y2, colour); // Draw flow port->drawFilledRect(x1, y1, FLOW_SIZE, getFlowLevel(), woopsiRGB(0, 0, 20)); x1 = (rect.width + FLOW_SIZE) / 2; x2 = x1; port->drawLine(x1, y1, x2, y2, colour); } if (hasLeftConnector()) { s16 x1 = 0; s16 y1 = rect.height / 2; s16 x2 = x1 + (rect.width / 2) - 1; s16 y2 = y1; port->drawLine(x1, y1, x2, y2, colour); } if (hasRightConnector()) { s16 x1 = rect.width / 2; s16 y1 = rect.height / 2; s16 x2 = x1 + (rect.width / 2) - 1; s16 y2 = y1; port->drawLine(x1, y1, x2, y2, colour); } }
// doDraw //--------------------------------------------------------------------------- void GameInfoView::doDraw(const Surface &viewArea, const Surface &clientArea) { char unitsBuf[64]; char killsBuf[64]; char lossesBuf[64]; char fragsBuf[64]; char timeBuf[64]; char pingBuf[64]; char gameBuf[64]; char fpsBuf[64]; iXY pos(2, 2); // Resize the game info rect to nothing so it can be resized based on the text, // to be used in it. gameInfoRect = getClientRect(); //gameInfoRect.max.x = 0; sprintf(gameBuf, "game %s", GameConfig::getGameTypeString() ); checkGameInfoRect(gameBuf); int unitPerPlayer = GameConfig::GetNumberUnits() / GameConfig::GetNumberPlayers(); sprintf(unitsBuf, "units %d/%d", int(UnitInterface::getUnitCount(PlayerInterface::getLocalPlayerIndex())), unitPerPlayer); checkGameInfoRect(unitsBuf); if( GameConfig::GetGameType() == _gametype_fraglimit ) { sprintf(fragsBuf, "frags %d/%d", getPlayerFrags(), GameConfig::GetFragLimit() ); checkGameInfoRect(fragsBuf); } else { sprintf(fragsBuf, "frags NA" ); checkGameInfoRect(fragsBuf); } /* sprintf(killsBuf, "kills %d", getPlayerKills()); checkGameInfoRect(killsBuf); sprintf(lossesBuf, "losses %d", getPlayerLosses()); checkGameInfoRect(lossesBuf); */ if( GameConfig::GetGameType() == _gametype_timelimit ) { sprintf(timeBuf, "time %s/%s", (const char*) getPlayerTime(), (const char*) getTimeLimit() ); checkGameInfoRect(timeBuf); } else { sprintf(timeBuf, "time %s", (const char *) getPlayerTime() ); checkGameInfoRect(timeBuf); } sprintf(pingBuf, "ping %.0f ms", NetworkState::ping_time ); checkGameInfoRect(pingBuf); sprintf(fpsBuf, "FPS %f", TimerInterface::getFPSAvg() ); checkGameInfoRect(fpsBuf); bltViewBackground(viewArea); clientArea.bltStringShadowed(pos, gameBuf, Color::white, Color::black); pos.y += 12; clientArea.bltStringShadowed(pos, unitsBuf, Color::white, Color::black); pos.y += 12; clientArea.bltStringShadowed(pos, fragsBuf, Color::white, Color::black); pos.y += 12; /* clientArea.bltStringShadowed(pos, killsBuf, Color::white, Color::black); pos.y += 12; clientArea.bltStringShadowed(pos, lossesBuf, Color::white, Color::black); pos.y += 12; */ clientArea.bltStringShadowed(pos, timeBuf, Color::white, Color::black); pos.y += 12; clientArea.bltStringShadowed(pos, pingBuf, Color::white, Color::black); pos.y += 12; clientArea.bltStringShadowed(pos, fpsBuf, Color::white, Color::black); pos.y += 12; View::doDraw(viewArea, clientArea); // Make sure the view stays in the screen when the view is resized. //resizeClientArea(gameInfoRect.getSize()); //moveTo(min); } // end GameInfoView::doDraw
LRESULT SplitterContainer::runProc(UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_CREATE : _splitter.init(_hInst, _hSelf, _splitterSize, _ratio, _dwSplitterStyle); return TRUE; case WM_COMMAND : { switch (LOWORD(wParam)) { case LEFT_ROTATION: rotateTo(LEFT); return TRUE; case RIGHT_ROTATION: rotateTo(RIGHT); return TRUE; NO_DEFAULT_CASE; } return TRUE; } case WM_RESIZE_CONTAINER : { RECT rc0, rc1; getClientRect(rc0); rc1.top = rc0.top += _y; rc1.bottom = rc0.bottom; rc1.left = rc0.left += _x; rc1.right = rc0.right; if (_dwSplitterStyle & SV_VERTICAL) { if (wParam != 0) { rc0.right = int(wParam); rc1.left = int(wParam) + _x + _splitter.getPhisicalSize(); rc1.right = rc1.right - rc1.left + _x; } } else //SV_HORIZONTAL { if (lParam != 0) { rc0.bottom = int(lParam); rc1.top = int(lParam) + _y + _splitter.getPhisicalSize(); rc1.bottom = rc1.bottom - rc1.top + _y; } } _pWin0->reSizeTo(rc0); _pWin1->reSizeTo(rc1); ::InvalidateRect(_splitter.getHSelf(), NULL, TRUE); return TRUE; } case WM_DOPOPUPMENU : { if ((_splitterMode != LEFT_FIX) && (_splitterMode != RIGHT_FIX) ) { POINT p; ::GetCursorPos(&p); if (!_hPopupMenu) { POINT p; ::GetCursorPos(&p); _hPopupMenu = ::CreatePopupMenu(); ::InsertMenu(_hPopupMenu, 1, MF_BYPOSITION, LEFT_ROTATION, TEXT("Rotate to left")); ::InsertMenu(_hPopupMenu, 0, MF_BYPOSITION, RIGHT_ROTATION, TEXT("Rotate to right")); } ::TrackPopupMenu(_hPopupMenu, TPM_LEFTALIGN, p.x, p.y, 0, _hSelf, NULL); } return TRUE; } case WM_GETSPLITTER_X : { if (_splitterMode == LEFT_FIX) return MAKELONG(_pWin0->getWidth(), LEFT_FIX); else if (_splitterMode == RIGHT_FIX) { int x = getWidth()-_pWin1->getWidth(); if (x < 0) x = 0; return MAKELONG(x, RIGHT_FIX); } else return MAKELONG(0, DYNAMIC); } case WM_GETSPLITTER_Y : { if (_splitterMode == LEFT_FIX) return MAKELONG(_pWin0->getHeight(), LEFT_FIX); else if (_splitterMode == RIGHT_FIX) { int y = getHeight()-_pWin1->getHeight(); if (y < 0) y = 0; return MAKELONG(y, RIGHT_FIX); } else return MAKELONG(0, DYNAMIC); } default : return ::DefWindowProc(_hSelf, message, wParam, lParam); } }
int CALLBACK ButtonX::windowProc(HWND hwnd , int message , WPARAM wParam, LPARAM lParam) { switch(message) { case WM_SETTEXT: ButtonX::fromHWND(hwnd)->_text = (char*) lParam; //break; return 0; case WM_GETTEXT: if (ButtonX::fromHWND(hwnd)->_duringPaint) { ((char*)lParam)[0] = 0; return 0; } //break; // strncpy((char*) lParam,ButtonX::fromHWND(hwnd)->_text , wParam); strncpy((char*) lParam,ButtonX::fromHWND(hwnd)->_text , wParam); return min(ButtonX::fromHWND(hwnd)->_text.length(), wParam-1); case WM_GETTEXTLENGTH: if (ButtonX::fromHWND(hwnd)->_duringPaint) return 0; //break; return ButtonX::fromHWND(hwnd)->_text.length(); case WM_PAINT: { ButtonX * bt = ButtonX::fromHWND(hwnd); //if (!bt->_icon) break; // standardowa obsĀ³uga... //int r = 1; HRGN hrgn=CreateRectRgn(0, 0, 0, 0); bt->_duringPaint=true; GetUpdateRgn(hwnd, hrgn, false); int r = 1; if (!bt->isFlat()) { r = CallWindowProc(ButtonX::buttonClassProc, hwnd, message, wParam, lParam); } InvalidateRgn(hwnd, hrgn, false); PAINTSTRUCT ps; HDC hdc; hdc = BeginPaint(hwnd, &ps); if (bt->isFlat()) { FillRgn(hdc, hrgn, GetSysColorBrush(COLOR_BTNFACE)); } RECT rc = {0,0,0,0}; bt->drawCaption(hdc, rc); EndPaint(hwnd, &ps); bt->_duringPaint=false; DeleteObject(hrgn); return r;} case WM_ENABLE: case WM_UPDATEUISTATE: { int r = CallWindowProc(ButtonX::buttonClassProc, hwnd, message, wParam, lParam); repaintWindow(hwnd); return r;} case WM_ERASEBKGND: return 0; case WM_SETFOCUS: //case BM_SETSTYLE: case BM_SETSTATE: // specjalnie dla W98 repaintWindow(hwnd); break; case WM_SETCURSOR: if (fromHWND(hwnd)->isFlat()) { SetCursor( LoadCursor(0, IDC_HAND) ); return true; } break; #ifndef STAMINA_KISS case WM_LBUTTONDOWN: { ButtonX* b = fromHWND(hwnd); S_ASSERT(b); b->_pressed = true; b->evtMouseDown(b, wParam); break;} case WM_LBUTTONUP: { ButtonX* b = fromHWND(hwnd); S_ASSERT(b); if (b->_pressed) { b->evtMouseUp(b, wParam); if (getClientRect(hwnd).contains(Point::fromLParam(lParam))) { b->evtClick(b); } } b->_pressed = false; break;} case WM_LBUTTONDBLCLK: { //SendMessage(hwnd, BM_CLICK, 0, 0); ButtonX* b = fromHWND(hwnd); S_ASSERT(b); b->evtMouseDown(b, wParam); b->evtMouseUp(b, wParam); b->evtClick(b); break;} case WM_MOUSELEAVE: //fromHWND(hwnd)->_pressed = false; break; case WM_MOUSEMOVE: _tipTarget->attachButton(fromHWND(hwnd)); ToolTipX::mouseMovement(GetParent(hwnd)); //if (wParam == MK_LBUTTON) { // fromHWND(hwnd)->_pressed = true; //} break; #endif case WM_DESTROY: delete ButtonX::fromHWND(hwnd); break; }; return CallWindowProc(ButtonX::buttonClassProc, hwnd, message, wParam, lParam); }
twRect rectForItem(int index) const{ twRect rt=getClientRect(); rt.x=0; rt.y=m_rowHeight*index; rt.h=m_rowHeight; return rt; }
// doDraw //--------------------------------------------------------------------------- void MenuTemplateView::doDraw(const Surface &viewArea, const Surface &clientArea) { //setWorldRect(); if (Desktop::getVisible("GameView")) { clientArea.bltLookup(getClientRect(), Palette::darkGray256.getColorArray()); clientArea.drawWindowsBorder(Color::white, Color::white, Color::white); } else { // Set the following to get does exist. if (backgroundSurface.getFrameCount() > 0) { backgroundSurface.blt(viewArea, 0, 0); } else { throw Exception("Where is the background surface?"); } //titlePackedSurface.blt(clientArea, bodyTextRect.min.x, 390); titlePackedSurface.bltBlend(clientArea, bodyTextRect.min.x, 390, Palette::colorTable6040); } // Set the following to get does exist. //if (titleSurface.getFrameCount() > 0) //{ // curTitleFlashTime += TimerInterface::getTimeSlice(); // // if (curTitleFlashTime > titleFlashTimeHalf * 2.0f) // { // // Since we are done, draw the solid image. // titleSurface.blt(viewArea, bodyTextRect.min.x, 394); // } // else if (curTitleFlashTime > titleFlashTimeHalf) // { // float titleFlashPercent = 1.0f - (float(curTitleFlashTime) / float(titleFlashTimeHalf)); // // titleSurface.bltBrightness(viewArea, iXY(bodyTextRect.min.x, 394), titleFlashPercent); // } // else // { // float titleFlashPercent = float(curTitleFlashTime) / float(titleFlashTimeHalf); // // titleSurface.bltBrightness(viewArea, iXY(bodyTextRect.min.x, 394), titleFlashPercent); // } //} else //{ // throw Exception("Where is the title surface?"); //} //iRect r(100, 100, 200, 110); //clientArea.fillRect(r, Color::chartreuse); //r.translate(iXY(0, 15)); //clientArea.fillRect(r, Color::cobaltGreen); //r.translate(iXY(0, 15)); //clientArea.fillRect(r, Color::emeraldGreen); //r.translate(iXY(0, 15)); //clientArea.fillRect(r, Color::forestGreen); //r.translate(iXY(0, 15)); //clientArea.fillRect(r, Color::darkOliveGreen); //r.translate(iXY(0, 15)); //clientArea.fillRect(r, Color::terreVerte); //r.translate(iXY(0, 15)); // Set the following to get does exist. //if (globeSurface.getFrameCount() > 0) //{ // globeSurface.nextFrame(); // globeSurface.blt(viewArea, 0, 0); // globeSurface.bltBlend(viewArea, 0, 0, Palette::colorTable8020); //} else //{ // throw Exception("Where is the f*****g globe surface?"); //} View::doDraw(viewArea, clientArea); //iXY pos; //pos.x = 0; //pos.y = SCREEN_YPIX - netPanzerLogo.getPixY(); //netPanzerLogo.nextFrame(); //netPanzerLogo.blt(viewArea, pos); } // end doDraw
BOOL CALLBACK AboutDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_INITDIALOG : { HWND compileDateHandle = ::GetDlgItem(_hSelf, IDC_BUILD_DATETIME); generic_string buildTime = TEXT("Build time : "); #ifdef UNICODE WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); buildTime += wmc->char2wchar(__DATE__, CP_ACP); buildTime += TEXT(" - "); buildTime += wmc->char2wchar(__TIME__, CP_ACP); #else buildTime += __DATE__; buildTime += TEXT(" - "); buildTime += __TIME__; #endif ::SendMessage(compileDateHandle, WM_SETTEXT, 0, (LPARAM)buildTime.c_str()); ::EnableWindow(compileDateHandle, FALSE); HWND licenceEditHandle = ::GetDlgItem(_hSelf, IDC_LICENCE_EDIT); ::SendMessage(licenceEditHandle, WM_SETTEXT, 0, (LPARAM)LICENCE_TXT); _emailLink.init(_hInst, _hSelf); //_emailLink.create(::GetDlgItem(_hSelf, IDC_AUTHOR_NAME), TEXT("mailto:[email protected]")); _emailLink.create(::GetDlgItem(_hSelf, IDC_AUTHOR_NAME), TEXT("http://notepad-plus-plus.org/contributors")); _pageLink.init(_hInst, _hSelf); _pageLink.create(::GetDlgItem(_hSelf, IDC_HOME_ADDR), TEXT("http://notepad-plus-plus.org/")); //_onLineHelp.init(_hInst, _hSelf); //_onLineHelp.create(::GetDlgItem(_hSelf, IDC_ONLINEHELP_ADDR), TEXT("http://notepad-plus.sourceforge.net/uk/generalFAQ.php")); getClientRect(_rc); NppParameters *pNppParam = NppParameters::getInstance(); ETDTProc enableDlgTheme = (ETDTProc)pNppParam->getEnableThemeDlgTexture(); if (enableDlgTheme) { enableDlgTheme(_hSelf, ETDT_ENABLETAB); redraw(); } return TRUE; } case WM_DRAWITEM : { HICON hIcon = (HICON)::LoadImage(_hInst, MAKEINTRESOURCE(IDI_CHAMELEON), IMAGE_ICON, 64, 64, LR_DEFAULTSIZE); DRAWITEMSTRUCT *pdis = (DRAWITEMSTRUCT *)lParam; ::DrawIconEx(pdis->hDC, 0, 0, hIcon, 64, 64, 0, NULL, DI_NORMAL); return TRUE; } case WM_COMMAND : { switch (wParam) { case IDCANCEL : case IDOK : display(false); return TRUE; default : break; } } case WM_DESTROY : { return TRUE; } } return FALSE; }
void Splitter::init( HINSTANCE hInst, HWND hPere, int splitterSize, double iSplitRatio, DWORD dwFlags) { if (hPere == NULL) throw std::runtime_error("Splitter::init : Parameter hPere is null"); if (iSplitRatio < 0) throw std::runtime_error("Splitter::init : Parameter iSplitRatio shoulds be 0 < ratio < 100"); Window::init(hInst, hPere); _spiltterSize = splitterSize; WNDCLASSEX wcex; DWORD dwExStyle = 0L; DWORD dwStyle = WS_CHILD | WS_VISIBLE; _hParent = hPere; _dwFlags = dwFlags; if (_dwFlags & SV_FIXED) { //Fixed spliter _isFixed = true; } else { if (iSplitRatio >= 100) { //cant be 100 % or more throw std::runtime_error("Splitter::init : Parameter iSplitRatio shoulds be 0 < ratio < 100"); } } _splitPercent = iSplitRatio; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = (WNDPROC)staticWndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = _hInst; wcex.hIcon = NULL; ::GetClientRect(_hParent, &_rect); if (_dwFlags & SV_HORIZONTAL) //Horizontal spliter { _rect.top = (LONG)((_rect.bottom * _splitPercent)/100); // y axis determined by the split% of the parent windows height _rect.left = 0; // x axis is always 0 _rect.bottom = _spiltterSize; // the height of the spliter // the width of the splitter remains the same as the width of the parent window. } else //Vertical spliter { // y axis is 0 always _rect.left = (LONG)((_rect.right * _splitPercent)/100); // x axis determined by split% of the parent windows width. _rect.right = _spiltterSize; // width of the spliter. //height of the spliter remains the same as the height of the parent window } if (!_isFixed) { if ((_dwFlags & SV_ENABLERDBLCLK) || (_dwFlags & SV_ENABLELDBLCLK)) { wcex.style = wcex.style | CS_DBLCLKS; // enable mouse double click messages. } } if (_isFixed) { wcex.hCursor = ::LoadCursor(NULL, IDC_ARROW); // if fixed spliter then choose default cursor type. if (_dwFlags & SV_HORIZONTAL) wcex.lpszClassName = TEXT("fxdnsspliter"); else wcex.lpszClassName = TEXT("fxdwespliter"); } else { if (_dwFlags & SV_HORIZONTAL) { //double sided arrow pointing north-south as cursor wcex.hCursor = ::LoadCursor(NULL,IDC_SIZENS); wcex.lpszClassName = TEXT("nsspliter"); } else { // double sided arrow pointing east-west as cursor wcex.hCursor = ::LoadCursor(NULL,IDC_SIZEWE); wcex.lpszClassName = TEXT("wespliter"); } } wcex.hbrBackground = (HBRUSH)(COLOR_3DFACE+1); wcex.lpszMenuName = NULL; wcex.hIconSm = NULL; if ((_dwFlags & SV_HORIZONTAL)&&(!_isHorizontalRegistered)) { RegisterClassEx(&wcex); _isHorizontalRegistered = true; } else if (isVertical()&&(!_isVerticalRegistered)) { RegisterClassEx(&wcex); _isVerticalRegistered = true; } else if ((_dwFlags & SV_HORIZONTAL)&&(!_isHorizontalFixedRegistered)) { RegisterClassEx(&wcex); _isHorizontalFixedRegistered = true; } else if (isVertical()&&(!_isVerticalFixedRegistered)) { RegisterClassEx(&wcex); _isVerticalFixedRegistered = true; } _hSelf = CreateWindowEx(dwExStyle, wcex.lpszClassName, TEXT(""), dwStyle, _rect.left, _rect.top, _rect.right, _rect.bottom, _hParent, NULL, _hInst, this); if (!_hSelf) throw std::runtime_error("Splitter::init : CreateWindowEx() function return null"); RECT rc; getClientRect(rc); //::GetClientRect(_hParent,&rc); _clickZone2TL.left = rc.left; _clickZone2TL.top = rc.top; int clickZoneWidth = getClickZone(WH::width); int clickZoneHeight = getClickZone(WH::height); _clickZone2TL.right = clickZoneWidth; _clickZone2TL.bottom = clickZoneHeight; _clickZone2BR.left = rc.right - clickZoneWidth; _clickZone2BR.top = rc.bottom - clickZoneHeight; _clickZone2BR.right = clickZoneWidth; _clickZone2BR.bottom = clickZoneHeight; display(); ::SendMessage(_hParent, WM_RESIZE_CONTAINER, _rect.left, _rect.top); }
LRESULT SplitterContainer::runProc(UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_CREATE : _splitter.init(_hInst, _hSelf, _splitterSize, _ratio, _dwSplitterStyle); return TRUE; case WM_COMMAND : { switch (LOWORD(wParam)) { case ROTATION_A_GAUCHE: rotateTo(LEFT); return TRUE; case ROTATION_A_DROITE: rotateTo(RIGHT); return TRUE; } return TRUE; } case WM_RESIZE_CONTAINER : { RECT rc0, rc1; getClientRect(rc0); rc1.top = rc0.top += _y; rc1.bottom = rc0.bottom; rc1.left = rc0.left += _x; rc1.right = rc0.right; if (_dwSplitterStyle & SV_VERTICAL) { if (wParam != 0) { rc0.right = int(wParam); rc1.left = int(wParam) + _x + _splitter.getPhysicalSize(); rc1.right = rc1.right - rc1.left + _x; } } else //SV_HORIZONTAL { if (lParam != 0) { rc0.bottom = int(lParam); rc1.top = int(lParam) + _y + _splitter.getPhysicalSize(); rc1.bottom = rc1.bottom - rc1.top + _y; } } _pWin0->reSizeTo(rc0); _pWin1->reSizeTo(rc1); ::InvalidateRect(_splitter.getHSelf(), NULL, TRUE); return TRUE; } case WM_DOPOPUPMENU : { if ((_splitterMode != LEFT_FIX) && (_splitterMode != RIGHT_FIX) ) { POINT p; ::GetCursorPos(&p); if (!_hPopupMenu) { POINT p; ::GetCursorPos(&p); _hPopupMenu = ::CreatePopupMenu(); ::InsertMenu(_hPopupMenu, 1, MF_BYPOSITION, ROTATION_A_GAUCHE, TEXT("Rotate to left")); ::InsertMenu(_hPopupMenu, 0, MF_BYPOSITION, ROTATION_A_DROITE, TEXT("Rotate to right")); } ::TrackPopupMenu(_hPopupMenu, TPM_LEFTALIGN, p.x, p.y, 0, _hSelf, NULL); } return TRUE; } case WM_GETSPLITTER_X : { if (_splitterMode == LEFT_FIX) return MAKELONG(_pWin0->getWidth(), LEFT_FIX); else if (_splitterMode == RIGHT_FIX) { int x = getWidth()-_pWin1->getWidth(); if (x < 0) x = 0; return MAKELONG(x, RIGHT_FIX); } else return MAKELONG(0, DYNAMIC); } case WM_GETSPLITTER_Y : { if (_splitterMode == LEFT_FIX) return MAKELONG(_pWin0->getHeight(), LEFT_FIX); else if (_splitterMode == RIGHT_FIX) { int y = getHeight()-_pWin1->getHeight(); if (y < 0) y = 0; return MAKELONG(y, RIGHT_FIX); } else return MAKELONG(0, DYNAMIC); } case WM_LBUTTONDBLCLK: { POINT pt; ::GetCursorPos(&pt); ::ScreenToClient(_splitter.getHSelf(), &pt); Window* targetWindow; if(this->isVertical()) targetWindow = pt.x < 0?_pWin0:_pWin1; else targetWindow = pt.y < 0?_pWin0:_pWin1; HWND parent = ::GetParent(getHSelf()); ::SendMessage(parent, NPPM_INTERNAL_SWITCHVIEWFROMHWND, 0, (LPARAM)targetWindow->getHSelf()); ::SendMessage(parent, WM_COMMAND, IDM_FILE_NEW, 0); return TRUE; } default : return ::DefWindowProc(_hSelf, message, wParam, lParam); } }
int ATOM_CurveEditor::keyValueToCoord (float value) const { unsigned canvasSize = (getClientRect().size.h > getCanvasSize().h) ? getClientRect().size.h : getCanvasSize().h; return canvasSize * _originValueAxis - value * _valueAxisUnitResolution - getScrollValue().y; }
void Splitter::drawSplitter() { PAINTSTRUCT ps; RECT rc, rcToDraw1, rcToDraw2, TLrc, BRrc; HDC hdc = ::BeginPaint(_hSelf, &ps); getClientRect(rc); if ((_spiltterSize >= 4) && (_dwFlags & SV_RESIZEWTHPERCNT)) { adjustZoneToDraw(TLrc, TOP_LEFT); adjustZoneToDraw(BRrc, BOTTOM_RIGHT); paintArrow(hdc, TLrc, isVertical()?ARROW_LEFT:ARROW_UP); } if (isVertical()) { rcToDraw2.top = (_dwFlags & SV_RESIZEWTHPERCNT)?_clickZone2TL.bottom:0; rcToDraw2.bottom = rcToDraw2.top + 2; rcToDraw1.top = rcToDraw2.top + 1; rcToDraw1.bottom = rcToDraw1.top + 2; } else { rcToDraw2.top = 1; rcToDraw2.bottom = 3; rcToDraw1.top = 2; rcToDraw1.bottom = 4; } int bottom = 0; if (_dwFlags & SV_RESIZEWTHPERCNT) bottom = (isVertical() ? rc.bottom - _clickZone2BR.bottom : rc.bottom); else bottom = rc.bottom; while (rcToDraw1.bottom <= bottom) { if (isVertical()) { rcToDraw2.left = 1; rcToDraw2.right = 3; rcToDraw1.left = 2; rcToDraw1.right = 4; } else { rcToDraw2.left = _clickZone2TL.right; rcToDraw2.right = rcToDraw2.left + 2; rcToDraw1.left = rcToDraw2.left; rcToDraw1.right = rcToDraw1.left + 2; } while (rcToDraw1.right <= (isVertical() ? rc.right : rc.right - _clickZone2BR.right)) { ::FillRect(hdc, &rcToDraw1, (HBRUSH)(RGB(0xFF, 0xFF, 0xFF))); ::FillRect(hdc, &rcToDraw2, (HBRUSH)(COLOR_3DSHADOW+1)); rcToDraw2.left += 4; rcToDraw2.right += 4; rcToDraw1.left += 4; rcToDraw1.right += 4; } rcToDraw2.top += 4; rcToDraw2.bottom += 4; rcToDraw1.top += 4; rcToDraw1.bottom += 4; } if ((_spiltterSize >= 4) && (_dwFlags & SV_RESIZEWTHPERCNT)) paintArrow(hdc, BRrc, isVertical()?ARROW_RIGHT:ARROW_DOWN); ::EndPaint(_hSelf, &ps); }
BOOL CALLBACK DocumentMap::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_INITDIALOG : { HWND hwndScintilla = (HWND)::SendMessage(_hParent, NPPM_CREATESCINTILLAHANDLE, 0, (LPARAM)_hSelf); _pScintillaEditView = (ScintillaEditView *)::SendMessage(_hParent, NPPM_INTERNAL_GETSCINTEDTVIEW, 0, (LPARAM)hwndScintilla); _pScintillaEditView->execute(SCI_SETZOOM, (WPARAM)-10, 0); _pScintillaEditView->execute(SCI_SETVSCROLLBAR, FALSE, 0); _pScintillaEditView->execute(SCI_SETHSCROLLBAR, FALSE, 0); _pScintillaEditView->showIndentGuideLine(false); _pScintillaEditView->display(); reloadMap(); _vzDlg.init(::GetModuleHandle(NULL), _hSelf); _vzDlg.doDialog(); (NppParameters::getInstance())->SetTransparent(_vzDlg.getHSelf(), 50); // 0 <= transparancy < 256 setSyntaxLiliting(); _pScintillaEditView->showMargin(0, false); _pScintillaEditView->showMargin(1, false); _pScintillaEditView->showMargin(2, false); _pScintillaEditView->showMargin(3, false); return TRUE; } case WM_SIZE: { if (_pScintillaEditView) { int width = LOWORD(lParam); int height = HIWORD(lParam); if (_vzDlg.isCreated()) { POINT pt = {0,0}; ::ClientToScreen(_hSelf, &pt); if (!_pScintillaEditView->isWrap()) ::MoveWindow(_pScintillaEditView->getHSelf(), 0, 0, width, height, TRUE); ::MoveWindow(_vzDlg.getHSelf(), pt.x, pt.y, width, height, TRUE); } } break; } case WM_NOTIFY: { switch (((LPNMHDR)lParam)->code) { case DMN_CLOSE: { ::SendMessage(_hParent, WM_COMMAND, IDM_VIEW_DOC_MAP, 0); return TRUE; } case DMN_SWITCHIN: { _vzDlg.display(); reloadMap(); return TRUE; } case DMN_SWITCHOFF: { _vzDlg.display(false); return TRUE; } case DMN_FLOATDROPPED: { RECT rc; getClientRect(rc); int width = rc.right - rc.left; int height = rc.bottom - rc.top; //RECT scinrc; //_pScintillaEditView->getClientRect(scinrc); //int scinrcWidth = scinrc.right - scinrc.left; //::MoveWindow(_pScintillaEditView->getHSelf(), 0, 0, scinrcWidth, height, TRUE); POINT pt = {0,0}; ::ClientToScreen(_hSelf, &pt); ::MoveWindow(_vzDlg.getHSelf(), pt.x, pt.y, width, height, TRUE); scrollMap(); return TRUE; } case NM_DBLCLK: { return TRUE; } default: break; } } return TRUE; case DOCUMENTMAP_SCROLL: { bool dir = (wParam != 0); moveMode mode = (lParam == 0)?perLine:perPage; scrollMap(dir, mode); } return TRUE; case DOCUMENTMAP_MOUSECLICKED: { int newPosY = HIWORD(lParam); int currentCenterPosY = _vzDlg.getCurrentCenterPosY(); int pixelPerLine = _pScintillaEditView->execute(SCI_TEXTHEIGHT, 0); int jumpDistance = newPosY - currentCenterPosY; int nbLine2jump = jumpDistance/pixelPerLine; (*_ppEditView)->execute(SCI_LINESCROLL, 0, nbLine2jump); scrollMap(); } return TRUE; case DOCUMENTMAP_MOUSEWHEEL: { (*_ppEditView)->mouseWheel(wParam, lParam); } return TRUE; default : return DockingDlgInterface::run_dlgProc(message, wParam, lParam); } return DockingDlgInterface::run_dlgProc(message, wParam, lParam); }