public
class
gsCalendar
extends
Activity
{
Context m_context ;
LinearLayout m_targetLayout ;
Button [] m_controlBtn ;
TextView [] m_viewTv ;
Calendar m_Calendar ;
LinearLayout [ ] m_lineLy ;
LinearLayout [ ] m_cellLy ;
TextView [ ] m_cellTextBtn ;
LinearLayout [ ] m_horizontalLine ;
LinearLayout [ ] m_verticalLine ;
int
m_startPos ;
int
m_lastDay ;
int
m_selDay ;
float
m_displayScale ;
float
m_textSize ;
float
m_topTextSize ;
int
m_tcHeight =
50
;
int
m_cWidth =
50
;
int
m_cHeight =
50
;
int
m_lineSize =
1
;
String [] m_dayText ={
"일"
,
"월"
,
"화"
,
"수"
,
"목"
,
"금"
,
"토"
} ;
Button m_preYearBtn ;
Button m_nextYearBtn ;
Button m_preMonthBtn ;
Button m_nextMonthBtn ;
TextView m_yearTv ;
TextView m_mothTv ;
TextView m_dayTv ;
public
gsCalendar( Context context, LinearLayout layout )
{
m_context = context ;
m_targetLayout = layout ;
m_Calendar = Calendar.getInstance( ) ;
m_lineLy =
new
LinearLayout[
7
] ;
m_cellLy =
new
LinearLayout[
7
*
7
] ;
m_cellTextBtn =
new
TextView[
7
*
7
] ;
m_horizontalLine =
new
LinearLayout[
6
] ;
m_verticalLine =
new
LinearLayout[
6
*
7
] ;
m_displayScale = context.getResources( ).getDisplayMetrics( ).density ;
m_topTextSize = m_displayScale *
12
.0f ;
m_textSize =
10
;
}
public
void
setCalendarSize(
int
width,
int
height )
{
m_cWidth = ( width - ( m_lineSize *
6
) ) /
7
;
m_cHeight = ( height - ( m_lineSize *
6
) ) /
7
;
m_tcHeight = ( height - ( m_lineSize *
6
) ) /
7
;
}
public
void
createViewItem( )
{
for
(
int
i =
0
; i <
13
; i++ )
{
if
( i %
2
==
0
)
{
m_lineLy[i/
2
] =
new
LinearLayout( m_context ) ;
m_targetLayout.addView( m_lineLy[i/
2
] ) ;
for
(
int
j =
0
; j <
13
; j++ )
{
if
( j %
2
==
0
)
{
int
pos = ( ( i /
2
) *
7
) + ( j /
2
) ;
Log.d(
"pos1"
,
""
+ pos ) ;
m_cellLy[ pos ] =
new
LinearLayout( m_context ) ;
m_cellTextBtn[ pos ] =
new
TextView( m_context ) ;
m_lineLy[ i /
2
].addView( m_cellLy[ pos ] ) ;
m_cellLy[ pos ].addView( m_cellTextBtn[ pos ] ) ;
}
else
{
int
pos = ( ( i /
2
) *
6
) + ( j -
1
) /
2
;
Log.d(
"pos2"
,
""
+ pos ) ;
m_verticalLine[ pos ] =
new
LinearLayout( m_context ) ;
m_lineLy[ i /
2
].addView( m_verticalLine[ pos ] ) ;
}
}
}
else
{
m_horizontalLine[ ( i -
1
) /
2
] =
new
LinearLayout( m_context ) ;
m_targetLayout.addView( m_horizontalLine[ ( i -
1
) /
2
] ) ;
}
}
}
public
void
setLayoutParams( )
{
m_targetLayout.setOrientation( LinearLayout.VERTICAL ) ;
if
( m_bgImgId !=
null
)
{
m_targetLayout.setBackgroundDrawable( m_bgImgId ) ;
}
for
(
int
i =
0
; i <
13
; i++ )
{
if
( i %
2
==
0
)
{
m_lineLy[i/
2
].setOrientation( LinearLayout.HORIZONTAL ) ;
m_lineLy[i/
2
].setLayoutParams(
new
LinearLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT ) ) ;
for
(
int
j =
0
; j <
7
; j++ )
{
int
cellnum = ( ( i /
2
) *
7
) + j ;
LinearLayout.LayoutParams param =
new
LinearLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT ) ;
m_cellLy[ cellnum ].setLayoutParams( param ) ;
m_cellTextBtn[ cellnum ].setGravity( Gravity.LEFT ) ;
if
( i ==
0
)
{
m_cellTextBtn[ cellnum ].setLayoutParams(
new
LinearLayout.LayoutParams( m_cWidth, m_tcHeight ) ) ;
m_cellTextBtn[ cellnum ].setTextSize( m_topTextSize ) ;
}
else
{
m_cellTextBtn[ cellnum ].setLayoutParams(
new
LinearLayout.LayoutParams( m_cWidth, m_cHeight ) ) ;
}
public
void
setLineParam( )
{
for
(
int
i =
0
; i <
6
; i ++ )
{
m_horizontalLine[ i ].setBackgroundColor( m_colorParam.m_lineColor ) ;
m_horizontalLine[ i ].setLayoutParams(
new
LinearLayout.LayoutParams( LayoutParams.FILL_PARENT, m_lineSize ) ) ;
}
for
(
int
i =
0
; i <
7
; i ++ )
{
for
(
int
j =
0
; j <
6
; j++ )
{
int
pos = ( i *
6
) + j ;
m_verticalLine[ pos ].setBackgroundColor( m_colorParam.m_lineColor ) ;
m_verticalLine[ pos ].setLayoutParams(
new
LinearLayout.LayoutParams( m_lineSize, LayoutParams.FILL_PARENT ) ) ;
}
}
}
}