author | waspe <waspe> | 2003-12-02 19:03:50 (UTC) |
---|---|---|
committer | waspe <waspe> | 2003-12-02 19:03:50 (UTC) |
commit | 64304e555fc3e06aa69fa2f4a514ee55b7aa98bc (patch) (unidiff) | |
tree | 3ce47189f43f18cccd42d326cf52977b339c744d /noncore/multimedia/tonleiter/pianoscale.cpp | |
parent | 7b74f202db22d458c43b2063ae128bf79b0e9777 (diff) | |
download | opie-64304e555fc3e06aa69fa2f4a514ee55b7aa98bc.zip opie-64304e555fc3e06aa69fa2f4a514ee55b7aa98bc.tar.gz opie-64304e555fc3e06aa69fa2f4a514ee55b7aa98bc.tar.bz2 |
*** empty log message ***
Diffstat (limited to 'noncore/multimedia/tonleiter/pianoscale.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/multimedia/tonleiter/pianoscale.cpp | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/noncore/multimedia/tonleiter/pianoscale.cpp b/noncore/multimedia/tonleiter/pianoscale.cpp new file mode 100644 index 0000000..3d5add2 --- a/dev/null +++ b/noncore/multimedia/tonleiter/pianoscale.cpp | |||
@@ -0,0 +1,96 @@ | |||
1 | #include "pianoscale.h" | ||
2 | |||
3 | #include <qpainter.h> | ||
4 | |||
5 | |||
6 | Menu::PianoScale::PianoScale(QWidget* parent,const char* name,WFlags f) | ||
7 | :QWidget(parent,name,f) | ||
8 | { | ||
9 | QColor black(0,0,0); | ||
10 | QColor white(255,255,255); | ||
11 | QColor mark(255,0,0); | ||
12 | blackBrush=QBrush(black); | ||
13 | whiteBrush=QBrush(white); | ||
14 | markBrush=QBrush(mark); | ||
15 | blackPen=QPen(black); | ||
16 | whitePen=QPen(white); | ||
17 | setBackgroundColor(QColor(0,0,255)); | ||
18 | } | ||
19 | //**************************************************************************** | ||
20 | Menu::PianoScale::~ PianoScale() | ||
21 | { | ||
22 | } | ||
23 | //**************************************************************************** | ||
24 | void Menu::PianoScale::paintEvent(QPaintEvent* pe) | ||
25 | { | ||
26 | QPainter p(this); | ||
27 | QRect mysize=rect(); | ||
28 | |||
29 | int pad=10; | ||
30 | int x0=pad; | ||
31 | int y0=pad; | ||
32 | int w0=mysize.width()-2*pad; | ||
33 | int h0=mysize.height()-2*pad; | ||
34 | |||
35 | int keypad=2; | ||
36 | if(mysize.width()>mysize.height()) | ||
37 | { | ||
38 | int div=(int)(w0/14.0); | ||
39 | int halftonewidth=(int)(div/3.0); | ||
40 | int halftoneheight=(int)((h0-2*keypad)*0.66); | ||
41 | for(int a=0;a<14;a++) | ||
42 | { | ||
43 | int x=x0+a*div; | ||
44 | |||
45 | p.setPen(blackPen); | ||
46 | p.setBrush(blackBrush); | ||
47 | p.drawRect(x,y0,div,h0); | ||
48 | |||
49 | p.setPen(whitePen); | ||
50 | p.setBrush(whiteBrush); | ||
51 | p.drawRect(x+keypad,y0+keypad,div-2*keypad,h0-2*keypad); | ||
52 | |||
53 | if(a==1 || a==2 || a==4 || a==5 || a==6 || a==8 || a==9 || a==11 || a==12 || a==13) | ||
54 | { | ||
55 | p.setPen(blackPen); | ||
56 | p.setBrush(blackBrush); | ||
57 | p.drawRect(x-halftonewidth,y0+keypad,2*halftonewidth,halftoneheight); | ||
58 | } | ||
59 | } | ||
60 | } | ||
61 | else | ||
62 | { | ||
63 | int div=(int)(w0/7.0); | ||
64 | int halfheight=(int)(h0/2.0); | ||
65 | int halftonewidth=(int)(div/3.0); | ||
66 | int halftoneheight=(int)((halfheight-2*keypad)*0.66); | ||
67 | for(int a=0;a<7;a++) | ||
68 | { | ||
69 | int x=x0+a*div; | ||
70 | |||
71 | p.setPen(blackPen); | ||
72 | p.setBrush(blackBrush); | ||
73 | p.drawRect(x,y0,div,h0); | ||
74 | |||
75 | p.setPen(whitePen); | ||
76 | p.setBrush(whiteBrush); | ||
77 | p.drawRect(x+keypad,y0+keypad,div-2*keypad,halfheight-2*keypad); | ||
78 | p.drawRect(x+keypad,y0+keypad+halfheight,div-2*keypad,halfheight-2*keypad); | ||
79 | |||
80 | if(a==1 || a==2 || a==4 || a==5 || a==6) | ||
81 | { | ||
82 | p.setPen(blackPen); | ||
83 | p.setBrush(blackBrush); | ||
84 | p.drawRect(x-halftonewidth,y0+keypad,2*halftonewidth,halftoneheight); | ||
85 | p.drawRect(x-halftonewidth,y0+keypad+halfheight,2*halftonewidth,halftoneheight); | ||
86 | } | ||
87 | } | ||
88 | } | ||
89 | } | ||
90 | //**************************************************************************** | ||
91 | void Menu::PianoScale::mousePressEvent(QMouseEvent* me) | ||
92 | { | ||
93 | } | ||
94 | //**************************************************************************** | ||
95 | //**************************************************************************** | ||
96 | |||