🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: de.comp.lang.c++
1 messages
1 total messages Started by Andreas Scherer Tue, 01 Aug 1995 10:41
Re: "Gummiband"
#180
Author: Andreas Scherer
Date: Tue, 01 Aug 1995 10:41
75 lines
2209 bytes
>ich tüftele an einem Graphikeditor und mir stellt sich nun das Problem 
>die von mir erstellten Vektorgarphiken mit sogenannten 
>"Gumiband"-Funktionen auszustatten. Soll heißen: ich klicke auf den DC 
>und ziehe dann gemütlich z.B. ein Rechteck auf. Anschließend wird dieses 
>dann direkt markiert, so daß ich es noch verschieben oder skalieren kann.
>In der MFC und bei VB 3.0 gibt´s wohl mittlerweile ne Klasse dafür, 
>gibt´s sowas denn nicht auch in der OWL 2.x?


#include <window.h>
#include <dc.h>

class TMyWin: public TWindow {
  TClientDC *dc;
  TPoint startPoint, endPoint;
  ...

public:
  TMyWin(TWindow *);
  void DrawRect();
  void EvLButtonDown(UINT,TPoint &);
  void EvMouseMove(UINT,TPoint &);
  void EvLButtonUp(UINT,TPoint &);
  ...
  DECLARE_RESPONSE_TABLE(TMyWin);
}

DEFINE_RESPONSE_TABLE1(TMyWin,TWindow)
  EV_WM_LBUTTONDOWN,
  EV_WM_MOUSEMOVE,
  EV_WM_LBUTTONUP,
  ...
END_RESPONSE_TABLE;

TMyWin::TMyWin(TWindow *parent): TWindow(parent), dc(0) {...}

void TMyWin::DrawRect() {
  if (startPoint != endPoint) {
    dc->MoveTo(startPoint);
    dc->LineTo(startPoint.x,endPoint.y);
    dc->LineTo(endPoint);
    dc->LineTo(endPoint.x,startPoint.y);
    dc->LineTo(startPoint);
    // nicht mit FrameRect(...);
  }
}

void TMyWin::EvLButtonDown(UINT,TPoint &point) {
  dc = new TClientDC(*this);
  dc->SetROP2(R2_NOT);
  startPoint = point;
  endPoint = point;
  SetCapture();
}

void TMyWin::EvMouseMove(UINT,TPoint &point) {
  if (dc) {
    DrawRect();
    endPoint = point;
    DrawRect();
  }
}

void TMyWin::EvLButtonUp(UINT,TPoint &point) {
  if (dc) {
    ReleaseCapture();
    DrawRect();
    delete dc;
    endPoint = point;
    // Rechteck: (startPoint,endPoint)
  }
}

Gruss Andreas.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads